| 1 | use encloserust-analyzer cargo enclose 1.2.1 crate/::encloserust-analyzer cargo enclose 1.2.1 enclose!; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#; |
| 3 | |
| 4 | fn mainrust-analyzer cargo enclose 1.2.1 main().() { |
| 5 | let clone_data = Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(0); |
| 6 | let add_data = Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(100); |
| 7 | |
| 8 | // I also note that any expressions can be used, but the main thing is to |
| 9 | // put the @ symbol at the beginning of the variable, and not forget to assign |
| 10 | // a new name to the variable using =>. |
| 11 | my_encloserust-analyzer cargo enclose 1.2.1 my_enclose().( |
| 12 | encloserust-analyzer cargo enclose 1.2.1 enclose!!((@*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Deref]deref().clone_data => mut clone_data: usize, @*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Deref]deref().(add_data.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().()) => add_data,) || { |
| 13 | // (@*clone_data => mut clone_data, @*(add_data.clone()) => add_data) -> |
| 14 | // let mut clone_data = *clone_data; |
| 15 | // let add_data = *(add_data.clone()); |
| 16 | |
| 17 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("#0 {:?}", clone_data); |
| 18 | clone_data += add_data; |
| 19 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("#1 {:?}", clone_data); |
| 20 | |
| 21 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(clone_data, 100); |
| 22 | }), |
| 23 | ); |
| 24 | |
| 25 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Deref]deref().clone_data, 0); |
| 26 | } |
| 27 | |
| 28 | #[inline] |
| 29 | fn my_encloserust-analyzer cargo enclose 1.2.1 my_enclose().<F: FnOncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnOnce#() -> R, R>(a: F) -> R { |
| 30 | a() |
| 31 | } |