dbg/
mut_macro.rs

1// File: ./examples/dbg/mut_macro.rs
2// clear && cargo run --example dbg --features ok -- mut_macro | bat -l rs
3// clear && cargo run --example dbg --features cp -- mut_macro | bat -l rs
4// clear && cargo run --example dbg --features err_01
5// clear && cargo run --example dbg --features err_02
6// clear && cargo run --example dbg --features err_03
7// clear && cargo run --example dbg --features err_04
8
9//=======
10
11
12
13//=======
14#[cfg(feature = "ok")]
15pub fn adjoin() {
16    // ANCHOR: feature-ok
17    // File: ./examples/dbg/mut_macro.rs
18    // #[cfg(feature = "ok")]
19
20    let mut string :String = format!("{}", "Hello");
21    string.push('!');
22    let ref_string = &string;
23    dbg!(ref_string);
24    dbg!(ref_string);
25
26    // ANCHOR_END: feature-ok
27}
28
29
30
31//=======
32#[cfg(feature = "cp")]
33pub fn adjoin() {
34    // ANCHOR: feature-cp
35    // File: ./examples/dbg/mut_macro.rs
36    // #[cfg(feature = "cp")]
37
38    let string :String = format!("{}", "Hello");
39    dbg!(std::mem::size_of_val(&string));
40    dbg!(&string);
41    dbg!(string);
42
43    // ANCHOR_END: feature-cp
44}
45
46
47
48//=======
49#[cfg(feature = "err_01")]
50pub fn adjoin() {
51    // ANCHOR: feature-error_01
52    // File: ./examples/dbg/mut_macro.rs
53    // ANCHOR = "error_01"
54    // error[E0382]: borrow of moved value: `string`
55
56    let string = format!("{}", "Hello");
57    dbg!(string);
58    dbg!(&string);
59
60    // ANCHOR_END: feature-error_01
61}
62
63
64
65//=======
66#[cfg(feature = "err_02")]
67pub fn adjoin() {
68    // ANCHOR: feature-error_02
69    // File: ./examples/dbg/mut_macro.rs
70    // ANCHOR = "error_02"
71    // error[E0382]: use of moved value: `string`
72
73    let string = format!("{}", "Hello");
74    dbg!(string);
75    dbg!(string);
76
77    // ANCHOR_END: feature-error_02
78}
79
80
81
82//=======
83#[cfg(feature = "err_03")]
84pub fn adjoin() {
85    // ANCHOR: feature-error_03
86    // File: ./examples/dbg/mut_macro.rs
87    // ANCHOR = "error_03"
88    // error[E0382]: use of moved value: `ref_mut_string`
89    dbg!("");
90
91    let mut string = format!("{}", "Hello");
92    string.push('!');
93    let ref_mut_string = &mut string;
94    dbg!(ref_mut_string);
95    dbg!(ref_mut_string);
96
97    // ANCHOR_END: feature-error_03
98}
99
100
101
102//=======
103#[cfg(feature = "err_04")]
104pub fn adjoin() {
105    // ANCHOR: feature-error_04
106    // File: ./examples/dbg/mut_macro.rs
107    // ANCHOR = "error_04"
108    // borrow of moved value: `ref_mut_string`
109
110    let mut string = format!("{}", "Hello");
111    string.push('!');
112    let ref_mut_string = &mut string;
113    dbg!(ref_mut_string);
114    println!("ref_mut_string = {}", ref_mut_string); // ref_mut_string is moved
115
116    // ANCHOR_END: feature-error_04
117}
118
119
120//=======
121#[cfg(all(
122    not(feature = "ok"),
123    not(feature = "cp"),
124    not(feature = "err_01"),
125    not(feature = "err_02"),
126    not(feature = "err_03"),
127    not(feature = "err_04"),
128))]
129pub fn adjoin() {
130    use aide::*;
131    hello();
132}