| 1 | use craterust-analyzer cargo ringbuf 0.3.3 crate/::HeapRbrust-analyzer cargo ringbuf 0.3.3 alias/HeapRb#; |
| 2 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#; |
| 3 | |
| 4 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 5 | fn pushrust-analyzer cargo ringbuf 0.3.3 tests/access/push().() { |
| 6 | let cap = 3; |
| 7 | 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); |
| 8 | let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 9 | |
| 10 | let vs_20 = (123, 456); |
| 11 | { |
| 12 | let (left, right) = unsafe { prod.free_space_as_slicesrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_space_as_slices().() }; |
| 13 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 3); |
| 14 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 15 | left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]new().(vs_20.0); |
| 16 | left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]new().(vs_20.1); |
| 17 | unsafe { prod.advancerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]advance().(2) }; |
| 18 | } |
| 19 | { |
| 20 | let (left, right) = unsafe { prod.free_space_as_slicesrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_space_as_slices().() }; |
| 21 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 1); |
| 22 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 23 | } |
| 24 | 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().(), vs_20.0); |
| 25 | 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().(), vs_20.1); |
| 26 | 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#); |
| 27 | |
| 28 | let vs_11 = (123, 456); |
| 29 | { |
| 30 | let (left, right) = unsafe { prod.free_space_as_slicesrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_space_as_slices().() }; |
| 31 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 1); |
| 32 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 2); |
| 33 | left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]new().(vs_11.0); |
| 34 | right[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]new().(vs_11.1); |
| 35 | unsafe { prod.advancerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]advance().(2) }; |
| 36 | } |
| 37 | { |
| 38 | let (left, right) = unsafe { prod.free_space_as_slicesrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_space_as_slices().() }; |
| 39 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 1); |
| 40 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 41 | } |
| 42 | 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().(), vs_11.0); |
| 43 | 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().(), vs_11.1); |
| 44 | 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#); |
| 45 | } |
| 46 | |
| 47 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 48 | fn pop_fullrust-analyzer cargo ringbuf 0.3.3 tests/access/pop_full().() { |
| 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, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 52 | |
| 53 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#cap { |
| 54 | prod.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(i as i32).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 55 | } |
| 56 | 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().(0), Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(0)); |
| 57 | |
| 58 | { |
| 59 | let (left, right) = unsafe { cons.as_uninit_slicesrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]as_uninit_slices().() }; |
| 60 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), cap); |
| 61 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 62 | for (i, x) in left.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().() { |
| 63 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { x.assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() }, i as i32); |
| 64 | } |
| 65 | unsafe { cons.advancerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]advance().(cap) }; |
| 66 | } |
| 67 | |
| 68 | 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); |
| 69 | 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#); |
| 70 | } |
| 71 | |
| 72 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 73 | fn pop_emptyrust-analyzer cargo ringbuf 0.3.3 tests/access/pop_empty().() { |
| 74 | let cap = 2; |
| 75 | 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); |
| 76 | let (_, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 77 | |
| 78 | { |
| 79 | let (left, right) = unsafe { cons.as_uninit_slicesrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]as_uninit_slices().() }; |
| 80 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 81 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 82 | unsafe { cons.advancerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]advance().(0) }; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 87 | fn poprust-analyzer cargo ringbuf 0.3.3 tests/access/pop().() { |
| 88 | let cap = 3; |
| 89 | 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); |
| 90 | let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 91 | |
| 92 | let vs_20 = (123, 456, 789); |
| 93 | 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().(vs_20.0), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 94 | 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().(vs_20.1), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 95 | 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().(vs_20.2), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 96 | 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().(0), Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(0)); |
| 97 | 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().(), 3); |
| 98 | { |
| 99 | let (left, right) = unsafe { cons.as_uninit_slicesrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]as_uninit_slices().() }; |
| 100 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 3); |
| 101 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 102 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() }, vs_20.0); |
| 103 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() }, vs_20.1); |
| 104 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() }, vs_20.2); |
| 105 | unsafe { cons.advancerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]advance().(2) }; |
| 106 | } |
| 107 | { |
| 108 | let (left, right) = unsafe { cons.as_uninit_slicesrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]as_uninit_slices().() }; |
| 109 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 1); |
| 110 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 111 | } |
| 112 | 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); |
| 113 | |
| 114 | let vs_11 = (654, 321); |
| 115 | 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().(vs_11.0), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 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().(vs_11.1), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 117 | 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().(0), Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(0)); |
| 118 | { |
| 119 | let (left, right) = unsafe { cons.as_uninit_slicesrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]as_uninit_slices().() }; |
| 120 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 1); |
| 121 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 2); |
| 122 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() }, vs_20.2); |
| 123 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { right[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() }, vs_11.0); |
| 124 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { right[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() }, vs_11.1); |
| 125 | unsafe { cons.advancerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]advance().(2) }; |
| 126 | } |
| 127 | { |
| 128 | let (left, right) = unsafe { cons.as_uninit_slicesrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]as_uninit_slices().() }; |
| 129 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 1); |
| 130 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 131 | } |
| 132 | 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); |
| 133 | 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#(vs_11.1)); |
| 134 | } |
| 135 | |
| 136 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 137 | fn push_returnrust-analyzer cargo ringbuf 0.3.3 tests/access/push_return().() { |
| 138 | let cap = 2; |
| 139 | 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); |
| 140 | let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 141 | |
| 142 | { |
| 143 | let (left, right) = unsafe { prod.free_space_as_slicesrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_space_as_slices().() }; |
| 144 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 2); |
| 145 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 146 | unsafe { prod.advancerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]advance().(0) }; |
| 147 | } |
| 148 | |
| 149 | { |
| 150 | let (left, right) = unsafe { prod.free_space_as_slicesrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_space_as_slices().() }; |
| 151 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 2); |
| 152 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 153 | left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]new().(12); |
| 154 | unsafe { prod.advancerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]advance().(1) }; |
| 155 | } |
| 156 | |
| 157 | { |
| 158 | let (left, right) = unsafe { prod.free_space_as_slicesrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_space_as_slices().() }; |
| 159 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 1); |
| 160 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 161 | left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]new().(34); |
| 162 | unsafe { prod.advancerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]advance().(1) }; |
| 163 | } |
| 164 | |
| 165 | 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().(), 12); |
| 166 | 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().(), 34); |
| 167 | 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#); |
| 168 | } |
| 169 | |
| 170 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 171 | fn pop_returnrust-analyzer cargo ringbuf 0.3.3 tests/access/pop_return().() { |
| 172 | let cap = 2; |
| 173 | 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); |
| 174 | let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 175 | |
| 176 | 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().(12), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 177 | 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().(34), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())); |
| 178 | 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().(0), Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(0)); |
| 179 | |
| 180 | { |
| 181 | let (left, right) = unsafe { cons.as_uninit_slicesrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]as_uninit_slices().() }; |
| 182 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 2); |
| 183 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 184 | unsafe { cons.advancerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]advance().(0) }; |
| 185 | } |
| 186 | |
| 187 | { |
| 188 | let (left, right) = unsafe { cons.as_uninit_slicesrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]as_uninit_slices().() }; |
| 189 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 2); |
| 190 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 191 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() }, 12); |
| 192 | unsafe { cons.advancerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]advance().(1) }; |
| 193 | } |
| 194 | |
| 195 | { |
| 196 | let (left, right) = unsafe { cons.as_uninit_slicesrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]as_uninit_slices().() }; |
| 197 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 1); |
| 198 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 199 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() }, 34); |
| 200 | unsafe { cons.advancerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]advance().(1) }; |
| 201 | } |
| 202 | |
| 203 | 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); |
| 204 | } |
| 205 | |
| 206 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 207 | fn push_poprust-analyzer cargo ringbuf 0.3.3 tests/access/push_pop().() { |
| 208 | let cap = 3; |
| 209 | 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); |
| 210 | let (mut prod, mut cons) = buf.splitrust-analyzer cargo ringbuf 0.3.3 ring_buffer/shared/impl#[`SharedRb<T, C>`]split().(); |
| 211 | |
| 212 | let vs_20 = (123, 456); |
| 213 | { |
| 214 | let (left, right) = unsafe { prod.free_space_as_slicesrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_space_as_slices().() }; |
| 215 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 3); |
| 216 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 217 | left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]new().(vs_20.0); |
| 218 | left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]new().(vs_20.1); |
| 219 | unsafe { prod.advancerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]advance().(2) }; |
| 220 | } |
| 221 | 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); |
| 222 | { |
| 223 | let (left, right) = unsafe { cons.as_uninit_slicesrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]as_uninit_slices().() }; |
| 224 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 2); |
| 225 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 226 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() }, vs_20.0); |
| 227 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() }, vs_20.1); |
| 228 | unsafe { cons.advancerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]advance().(2) }; |
| 229 | } |
| 230 | 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); |
| 231 | |
| 232 | let vs_11 = (123, 456); |
| 233 | { |
| 234 | let (left, right) = unsafe { prod.free_space_as_slicesrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]free_space_as_slices().() }; |
| 235 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 1); |
| 236 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 2); |
| 237 | left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]new().(vs_11.0); |
| 238 | right[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]new().(vs_11.1); |
| 239 | unsafe { prod.advancerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]advance().(2) }; |
| 240 | } |
| 241 | 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); |
| 242 | { |
| 243 | let (left, right) = unsafe { cons.as_uninit_slicesrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]as_uninit_slices().() }; |
| 244 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(left.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 1); |
| 245 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(right.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 1); |
| 246 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() }, vs_11.0); |
| 247 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { right[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() }, vs_11.1); |
| 248 | unsafe { cons.advancerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]advance().(2) }; |
| 249 | } |
| 250 | 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); |
| 251 | } |