fn no_context_and_fn_type() {
    let obj1 = MyStruct::new("Hello", 15);
    let obj2 = MyStruct::new("More Text", 10);

    // We can use "func1" and "closure1" almost interchangeably.
    let closure1 = |x: &MyStruct| x.get_number() + 3;
    assert_eq!(closure1(&obj1), 18);
    assert_eq!(closure1(&obj2), 13);

    fn func1(x: &MyStruct) -> u32 {
        x.get_number() + 3
    }
    assert_eq!(func1(&obj1), 18);
    assert_eq!(func1(&obj2), 13);

    // When a closure does not depend on context at all, the type of our closure is "fn".
    is_fn(closure1);
    is_Fn(&closure1);
    is_FnMut(&closure1);
    is_FnOnce(&closure1);
}
// This is about as simple as we can get. This closure adds three to the number of any
// object of type "MyStruct" it has been given.
This is about as simple as we can get. This closure adds three to the number of any
object of type "MyStruct" it has been given.
This is about as simple as we can get . This closure adds three to the number of any object of type " MyStruct " it has been given .
fn no_context_and_fn_type() {
    let obj1 = MyStruct::new("Hello", 15);
    let obj2 = MyStruct::new("More Text", 10);
    // We can use "func1" and "closure1" almost interchangeably.
    let closure1 = |x: &MyStruct| x.get_number() + 3;
    assert_eq!(closure1(&obj1), 18);
    assert_eq!(closure1(&obj2), 13);
    fn func1(x: &MyStruct) -> u32 {
        x.get_number() + 3
    }
    assert_eq!(func1(&obj1), 18);
    assert_eq!(func1(&obj2), 13);
    // When a closure does not depend on context at all, the type of our closure is "fn".
    is_fn(closure1);
    is_Fn(&closure1);
    is_FnMut(&closure1);
    is_FnOnce(&closure1);
}
fn no_context_and_fn_type ( ) { let obj1 = MyStruct :: new ( " " , 15 ) ; let obj2 = MyStruct :: new ( " " , 10 ) ; // We can use "func1" and "closure1" almost interchangeably. let closure1 = | x : & MyStruct | x . get_number ( ) + 3 ; assert_eq ! ( closure1 ( obj1 ) 18 ) ; assert_eq ! ( closure1 ( obj2 ) 13 ) ; fn func1 ( x : & MyStruct ) -> u32 { x . get_number ( ) + 3 } assert_eq ! ( func1 ( obj1 ) 18 ) ; assert_eq ! ( func1 ( obj2 ) 13 ) ; // When a closure does not depend on context at all, the type of our closure is "fn". is_fn ( closure1 ) ; is_Fn ( & closure1 ) ; is_FnMut ( & closure1 ) ; is_FnOnce ( & closure1 ) ; }
This is about as simple as we can get.
This is about as simple as we can get .