| 1 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/::atomicrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/::AtomicU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU8#; |
| 2 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/::atomicrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#; |
| 3 | use encloserust-analyzer cargo enclose 1.2.1 crate/::encrust-analyzer cargo enclose 1.2.1 enclose!; |
| 4 | |
| 5 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 6 | fn clone_count_operationsrust-analyzer cargo enclose 1.2.1 clone_count_operations().() { |
| 7 | static CHECK_COUNT_OPERATIONSrust-analyzer cargo enclose 1.2.1 CHECK_COUNT_OPERATIONS.: AtomicU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU8# = AtomicU8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU8#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU8]new().(0); |
| 8 | struct CleverTyperust-analyzer cargo enclose 1.2.1 CleverType#; |
| 9 | |
| 10 | impl Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# for CleverTyperust-analyzer cargo enclose 1.2.1 CleverType# { |
| 11 | #[inline] |
| 12 | fn clonerust-analyzer cargo enclose 1.2.1 impl#[CleverType][Clone]clone().(&self) -> Selfrust-analyzer cargo enclose 1.2.1 impl#[CleverType][Clone] { |
| 13 | let _del = CHECK_COUNT_OPERATIONSrust-analyzer cargo enclose 1.2.1 CHECK_COUNT_OPERATIONS..fetch_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU8]fetch_add().(1, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::SeqCstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#SeqCst#); |
| 14 | |
| 15 | CleverTyperust-analyzer cargo enclose 1.2.1 CleverType# |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | let data = CleverTyperust-analyzer cargo enclose 1.2.1 CleverType#; |
| 20 | |
| 21 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(CHECK_COUNT_OPERATIONSrust-analyzer cargo enclose 1.2.1 CHECK_COUNT_OPERATIONS..loadrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU8]load().(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::SeqCstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#SeqCst#), 0); //Checking the number of operations |
| 22 | encrust-analyzer cargo enclose 1.2.1 enclose!!((data => d) || { |
| 23 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(CHECK_COUNT_OPERATIONSrust-analyzer cargo enclose 1.2.1 CHECK_COUNT_OPERATIONS..loadrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU8]load().(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::SeqCstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#SeqCst#), 1); //Checking the number of operations |
| 24 | |
| 25 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/::spawnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/spawn().(encrust-analyzer cargo enclose 1.2.1 enclose!!((d,) move || { |
| 26 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(CHECK_COUNT_OPERATIONSrust-analyzer cargo enclose 1.2.1 CHECK_COUNT_OPERATIONS..loadrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU8]load().(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::SeqCstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#SeqCst#), 2); //Checking the number of operations |
| 27 | |
| 28 | encrust-analyzer cargo enclose 1.2.1 enclose!!((d) || { |
| 29 | encrust-analyzer cargo enclose 1.2.1 enclose!!((d => _d, d => _d2) move || { //'Move 'is not mandatory here, but since the semantics of the macro are different, we will leave it here for tests. |
| 30 | |
| 31 | })(); |
| 32 | })(); |
| 33 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(CHECK_COUNT_OPERATIONSrust-analyzer cargo enclose 1.2.1 CHECK_COUNT_OPERATIONS..loadrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU8]load().(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::SeqCstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#SeqCst#), 5); //Checking the number of operations |
| 34 | |
| 35 | |
| 36 | })).joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/join_handle/impl#[`JoinHandle<T>`]join().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 37 | |
| 38 | })(); |
| 39 | |
| 40 | let _manclone = data.clonerust-analyzer cargo enclose 1.2.1 impl#[CleverType][Clone]clone().(); |
| 41 | |
| 42 | //Checking the number of operations, |
| 43 | //Closure = 2 |
| 44 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(CHECK_COUNT_OPERATIONSrust-analyzer cargo enclose 1.2.1 CHECK_COUNT_OPERATIONS..loadrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU8]load().(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::SeqCstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#SeqCst#), 6); |
| 45 | } |