Skip to content

Commit

Permalink
Merge pull request #251 from dev-chee/master
Browse files Browse the repository at this point in the history
Fix code sample 2-5.
  • Loading branch information
ZhangHanDong authored Oct 30, 2019
2 parents e18c180 + fc49f13 commit 809fcc8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ch02/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn ownership() {
let other = place1;
println!("{:?}", other);
let other = place2;
println!("{:?}", other); // other value used here after move
println!("{:?}", place2); // place2 value used here after move
}

/// # 引用
Expand Down
6 changes: 3 additions & 3 deletions src/ch02/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ pub fn closure(){
/// Basic usage:
///
/// ```
/// pub fn math<F: Fn() -> i32>(op: F) -> i32 {
/// pub fn closure_math<F: Fn() -> i32>(op: F) -> i32 {
/// op()
/// }
/// let a = 2;
/// let b = 3;
/// assert_eq!(math(|| a + b), 5);
/// assert_eq!(math(|| a * b), 6);
/// assert_eq!(closure_math(|| a + b), 5);
/// assert_eq!(closure_math(|| a * b), 6);
/// ```
pub fn closure_math<F: Fn() -> i32>(op: F) -> i32 {
op()
Expand Down
4 changes: 2 additions & 2 deletions src/ch02/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
pub fn bool_type() {
let x = true;
let y: bool = false;
let x = 5;
if x > 1 { println!( "x is bigger than 1")};
let i = 5;
if i > 1 { println!( "i is bigger than 1")};
assert_eq!(x as i32, 1);
assert_eq!(y as i32, 0);
}
Expand Down

0 comments on commit 809fcc8

Please sign in to comment.