1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! 第二章:语言精要
//!

/// # Examples
///
/// Basic usage:
///
/// ```
/// pub fn title(){
///   println!("第2章:{}", "语言精要");
/// }
/// title();
/// ```
pub fn title(){
    println!("第2章:{}", "语言精要");
}

/// # answer
///
/// Basic usage:
///
/// ```
/// // extern crate std;      // 声明语句
/// // use std::prelude::v1::*;  // 声明语句
///
/// pub fn answer() -> (){
///     let a = 40;  // 声明语句
///     let b = 2;   // 声明语句
///     assert_eq!(sum(a, b), 42); // 宏语句
/// }
///
/// pub fn sum(a: i32, b: i32) -> i32 {
///     a + b  // 表达式
/// }
///
/// answer(); // 表达式语句
/// ```

pub fn answer() -> (){
    let a = 40;
    let b = 2;
    assert_eq!(sum(a, b), 42);
}
pub fn sum(a: i32, b: i32) -> i32 {
    a + b
}

pub mod binding;
pub mod function;
pub mod control_flow;
pub mod collections;
pub mod primitives;
pub mod enums;
pub mod structs;
pub mod smart_pointer;
pub mod generics_trait;
pub mod errors_handle;
pub mod annotation;