closure/
immut_string.rs

1// File: ./bin-hello/examples/closure/immut_string/mod.rs
2// clear && cargo run --example closure --features ok -- immut_string | bat -l cmd
3// clear && cargo run --example closure --features err_01
4// clear && cargo run --example closure -- immut_string
5
6//=======
7
8
9//=======
10#[cfg(feature = "ok")]
11pub fn adjoin() {
12    // ANCHOR: feature-ok
13    // File: ./bin-hello/examples/closure/immut_string/mod.rs
14    // #[cfg(feature = "ok")]
15
16    let string_instance: String = "Hello".to_string();
17
18    println!("Before fn = {:p}", &string_instance);
19    let closure_instance = |hello: &str| {
20        println!("{} Friend!", hello);
21        println!("Inside fn = {:p}", &hello);
22    };
23    closure_instance(&string_instance);
24    println!("After fn = {:p}", &string_instance);
25
26    println!("{} World!", string_instance);
27
28    // ANCHOR_END: feature-ok
29}
30
31//=======
32#[cfg(feature = "err_01")]
33pub fn adjoin() {
34    // ANCHOR: feature-err
35    // File: ./bin-hello/examples/closure/immut_string/mod.rs
36    // #[cfg(feature = "err_01")]
37
38    let string_instance: String = "Hello".to_string();
39
40    let closure_instance = |hello: String| println!("{} Friend!", hello);
41    closure_instance(string_instance);
42
43    println!("{} World!", string_instance);
44
45    // ANCHOR_END: feature-err
46}
47
48
49//=======
50#[cfg(all(not(feature = "ok"), not(feature = "err_01")))]
51pub fn adjoin() {
52    use aide::hello;
53    hello();
54}