| 1 | use craterust-analyzer cargo ringbuf 0.3.3 crate/::HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#; |
| 2 | #[cfg(feature = "std")] |
| 3 | use 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/; |
| 4 | |
| 5 | fn head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().<T>(ring_buffer: &HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#<T>) -> (usize, usize) { |
| 6 | use craterust-analyzer cargo ringbuf 0.3.3 crate/::ring_bufferrust-analyzer cargo ringbuf 0.3.3 ring_buffer/::RbBaserust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbBase#; |
| 7 | |
| 8 | (ring_buffer.headrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`][`RbBase<T>`]head().(), ring_buffer.tailrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`][`RbBase<T>`]tail().()) |
| 9 | } |
| 10 | |
| 11 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 12 | fn capacityrust-analyzer cargo ringbuf 0.3.3 tests/basic/capacity().() { |
| 13 | use craterust-analyzer cargo ringbuf 0.3.3 crate/::Rbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#; |
| 14 | |
| 15 | let cap = 13; |
| 16 | let buf = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(cap); |
| 17 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf.capacityrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#capacity().(), cap); |
| 18 | } |
| 19 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 20 | fn split_capacityrust-analyzer cargo ringbuf 0.3.3 tests/basic/split_capacity().() { |
| 21 | let cap = 13; |
| 22 | let buf = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(cap); |
| 23 | let (prod, cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 24 | |
| 25 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.capacityrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]capacity().(), cap); |
| 26 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.capacityrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]capacity().(), cap); |
| 27 | } |
| 28 | |
| 29 | #[cfg(feature = "std")] |
| 30 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 31 | fn split_threadsrust-analyzer cargo ringbuf 0.3.3 tests/basic/split_threads().() { |
| 32 | let buf = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(10); |
| 33 | let (prod, cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 34 | |
| 35 | let pjh = 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().(move || { |
| 36 | let _ = prod; |
| 37 | }); |
| 38 | |
| 39 | let cjh = 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().(move || { |
| 40 | let _ = cons; |
| 41 | }); |
| 42 | |
| 43 | pjh.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().(); |
| 44 | cjh.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().(); |
| 45 | } |
| 46 | |
| 47 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 48 | fn pushrust-analyzer cargo ringbuf 0.3.3 tests/basic/push().() { |
| 49 | let cap = 2; |
| 50 | let buf = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(cap); |
| 51 | let (mut prod, _) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 52 | |
| 53 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(prod.rbrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]rb().()), (0, 0)); |
| 54 | |
| 55 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(123), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 56 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(prod.rbrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]rb().()), (0, 1)); |
| 57 | |
| 58 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(234), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 59 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(prod.rbrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]rb().()), (0, 2)); |
| 60 | |
| 61 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(345), Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(345)); |
| 62 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(prod.rbrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]rb().()), (0, 2)); |
| 63 | } |
| 64 | |
| 65 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 66 | fn pop_emptyrust-analyzer cargo ringbuf 0.3.3 tests/basic/pop_empty().() { |
| 67 | let cap = 2; |
| 68 | let buf = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(cap); |
| 69 | let (_, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 70 | |
| 71 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(cons.rbrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]rb().()), (0, 0)); |
| 72 | |
| 73 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.poprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 74 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(cons.rbrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]rb().()), (0, 0)); |
| 75 | } |
| 76 | |
| 77 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 78 | fn push_pop_onerust-analyzer cargo ringbuf 0.3.3 tests/basic/push_pop_one().() { |
| 79 | let cap = 2; |
| 80 | let buf = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(cap); |
| 81 | let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 82 | |
| 83 | let vcap = 2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().cap; |
| 84 | let values = [12, 34, 56, 78, 90]; |
| 85 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(cons.rbrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]rb().()), (0, 0)); |
| 86 | |
| 87 | for (i, v) in values.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 88 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().v), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 89 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(cons.rbrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]rb().()), (i %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap, (i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap)); |
| 90 | |
| 91 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.poprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().v); |
| 92 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(cons.rbrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]rb().()), ((i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap, (i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap)); |
| 93 | |
| 94 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.poprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 95 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(cons.rbrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]rb().()), ((i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap, (i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap)); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 100 | fn push_pop_allrust-analyzer cargo ringbuf 0.3.3 tests/basic/push_pop_all().() { |
| 101 | let cap = 2; |
| 102 | let buf = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(cap); |
| 103 | let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 104 | |
| 105 | let vcap = 2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().cap; |
| 106 | let values = [(12, 34, 13), (56, 78, 57), (90, 10, 91)]; |
| 107 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(cons.rbrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]rb().()), (0, 0)); |
| 108 | |
| 109 | for (i, v) in values.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 110 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(v.0), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 111 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(cons.rbrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]rb().()), (cap *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). i %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap, (cap *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap)); |
| 112 | |
| 113 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(v.1), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 114 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(cons.rbrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]rb().()), (cap *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). i %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap, (cap *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 2) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap)); |
| 115 | |
| 116 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(v.2).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(), v.2); |
| 117 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(cons.rbrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]rb().()), (cap *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). i %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap, (cap *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 2) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap)); |
| 118 | |
| 119 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.poprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), v.0); |
| 120 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 121 | head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(cons.rbrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]rb().()), |
| 122 | ((cap *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap, (cap *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 2) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap) |
| 123 | ); |
| 124 | |
| 125 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.poprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), v.1); |
| 126 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 127 | head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(cons.rbrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]rb().()), |
| 128 | ((cap *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 2) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap, (cap *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 2) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap) |
| 129 | ); |
| 130 | |
| 131 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.poprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 132 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 133 | head_tailrust-analyzer cargo ringbuf 0.3.3 tests/basic/head_tail().(cons.rbrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]rb().()), |
| 134 | ((cap *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 2) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap, (cap *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). i +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 2) %rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). vcap) |
| 135 | ); |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 140 | fn empty_fullrust-analyzer cargo ringbuf 0.3.3 tests/basic/empty_full().() { |
| 141 | let buf = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(1); |
| 142 | let (mut prod, cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 143 | |
| 144 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(prod.is_emptyrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]is_empty().()); |
| 145 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cons.is_emptyrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]is_empty().()); |
| 146 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().prod.is_fullrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]is_full().()); |
| 147 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().cons.is_fullrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]is_full().()); |
| 148 | |
| 149 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(123), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 150 | |
| 151 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().prod.is_emptyrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]is_empty().()); |
| 152 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().cons.is_emptyrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]is_empty().()); |
| 153 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(prod.is_fullrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]is_full().()); |
| 154 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cons.is_fullrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]is_full().()); |
| 155 | } |
| 156 | |
| 157 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 158 | fn len_remainingrust-analyzer cargo ringbuf 0.3.3 tests/basic/len_remaining().() { |
| 159 | let buf = HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#::<i32>::newrust-analyzer cargo ringbuf 0.3.3 ring_buffer/init/impl#[`SharedRb<T, Vec<MaybeUninit<T>>>`]new().(2); |
| 160 | let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 161 | |
| 162 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.lenrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]len().(), 0); |
| 163 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]len().(), 0); |
| 164 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.free_lenrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_len().(), 2); |
| 165 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.free_lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]free_len().(), 2); |
| 166 | |
| 167 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(123), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 168 | |
| 169 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.lenrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]len().(), 1); |
| 170 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]len().(), 1); |
| 171 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.free_lenrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_len().(), 1); |
| 172 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.free_lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]free_len().(), 1); |
| 173 | |
| 174 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(456), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 175 | |
| 176 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.lenrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]len().(), 2); |
| 177 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]len().(), 2); |
| 178 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.free_lenrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_len().(), 0); |
| 179 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.free_lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]free_len().(), 0); |
| 180 | |
| 181 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.poprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(123)); |
| 182 | |
| 183 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.lenrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]len().(), 1); |
| 184 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]len().(), 1); |
| 185 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.free_lenrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_len().(), 1); |
| 186 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.free_lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]free_len().(), 1); |
| 187 | |
| 188 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.poprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(456)); |
| 189 | |
| 190 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.lenrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]len().(), 0); |
| 191 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]len().(), 0); |
| 192 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.free_lenrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_len().(), 2); |
| 193 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.free_lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]free_len().(), 2); |
| 194 | |
| 195 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(789), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 196 | |
| 197 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.lenrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]len().(), 1); |
| 198 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]len().(), 1); |
| 199 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prod.free_lenrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_len().(), 1); |
| 200 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cons.free_lenrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]free_len().(), 1); |
| 201 | } |