| 1 | // vim: tw=80 |
| 2 | |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 4 | borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::{Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#, BorrowMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/BorrowMut#}, |
| 5 | cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#, |
| 6 | collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::DefaultHasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/DefaultHasher#, |
| 7 | convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::TryIntorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#, |
| 8 | hashrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/::{Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#}, |
| 9 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 10 | threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/, |
| 11 | }; |
| 12 | |
| 13 | use divbufrust-analyzer cargo divbuf 0.4.1 crate/::*; |
| 14 | use lazy_staticrust-analyzer cargo lazy_static 1.5.0 crate/::lazy_staticrust-analyzer cargo lazy_static 1.5.0 lazy_static!; |
| 15 | |
| 16 | fn simple_hashrust-analyzer cargo divbuf 0.4.1 simple_hash().<T: Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#>(t: &T) -> u64 { |
| 17 | let mut s = DefaultHasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/DefaultHasher#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/impl#[DefaultHasher]new().(); |
| 18 | t.hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#hash().(&mut s); |
| 19 | s.finishrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/impl#[DefaultHasher][Hasher]finish().() |
| 20 | } |
| 21 | |
| 22 | // |
| 23 | // Chunks methods |
| 24 | // |
| 25 | mod chunksrust-analyzer cargo divbuf 0.4.1 chunks/ { |
| 26 | use superrust-analyzer cargo divbuf 0.4.1 crate/::*; |
| 27 | |
| 28 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 29 | pub fn iterrust-analyzer cargo divbuf 0.4.1 chunks/iter().() { |
| 30 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 31 | let db = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 32 | let mut chunks = db.into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(3); |
| 33 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&chunks.nextrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]next().().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/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &[1, 2, 3][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 34 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&chunks.nextrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]next().().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/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &[4, 5, 6][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 35 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(chunks.nextrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 36 | } |
| 37 | |
| 38 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 39 | #[should_panic] |
| 40 | pub fn zerorust-analyzer cargo divbuf 0.4.1 chunks/zero().() { |
| 41 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 42 | let db = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 43 | db.into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(0); |
| 44 | } |
| 45 | |
| 46 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 47 | pub fn size_hintrust-analyzer cargo divbuf 0.4.1 chunks/size_hint().() { |
| 48 | let dbs = |
| 49 | DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]); |
| 50 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 51 | dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(1).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]size_hint().(), |
| 52 | (12, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(12)) |
| 53 | ); |
| 54 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 55 | dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(2).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]size_hint().(), |
| 56 | (6, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(6)) |
| 57 | ); |
| 58 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 59 | dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(3).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]size_hint().(), |
| 60 | (4, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4)) |
| 61 | ); |
| 62 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 63 | dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(4).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]size_hint().(), |
| 64 | (3, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)) |
| 65 | ); |
| 66 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 67 | dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(5).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]size_hint().(), |
| 68 | (3, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)) |
| 69 | ); |
| 70 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 71 | dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(6).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]size_hint().(), |
| 72 | (2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)) |
| 73 | ); |
| 74 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 75 | dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(7).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]size_hint().(), |
| 76 | (2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)) |
| 77 | ); |
| 78 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 79 | dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(8).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]size_hint().(), |
| 80 | (2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)) |
| 81 | ); |
| 82 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 83 | dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(9).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]size_hint().(), |
| 84 | (2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)) |
| 85 | ); |
| 86 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 87 | dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(10).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]size_hint().(), |
| 88 | (2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)) |
| 89 | ); |
| 90 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 91 | dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(11).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]size_hint().(), |
| 92 | (2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)) |
| 93 | ); |
| 94 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 95 | dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]into_chunks().(12).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[Chunks][Iterator]size_hint().(), |
| 96 | (1, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1)) |
| 97 | ); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | // |
| 102 | // ChunksMut methods |
| 103 | // |
| 104 | mod chunks_mutrust-analyzer cargo divbuf 0.4.1 chunks_mut/ { |
| 105 | use superrust-analyzer cargo divbuf 0.4.1 crate/::*; |
| 106 | |
| 107 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 108 | pub fn iterrust-analyzer cargo divbuf 0.4.1 chunks_mut/iter().() { |
| 109 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 110 | let dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 111 | let mut chunks = dbm.into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(3); |
| 112 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&chunks.nextrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]next().().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/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &[1, 2, 3][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 113 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&chunks.nextrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]next().().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/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &[4, 5, 6][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 114 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(chunks.nextrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 115 | } |
| 116 | |
| 117 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 118 | #[should_panic] |
| 119 | pub fn zerorust-analyzer cargo divbuf 0.4.1 chunks_mut/zero().() { |
| 120 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 121 | let dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 122 | dbm.into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(0); |
| 123 | } |
| 124 | |
| 125 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 126 | pub fn size_hintrust-analyzer cargo divbuf 0.4.1 chunks_mut/size_hint().() { |
| 127 | let dbs = |
| 128 | DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]); |
| 129 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 130 | dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(1).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]size_hint().(), |
| 131 | (12, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(12)) |
| 132 | ); |
| 133 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 134 | dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(2).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]size_hint().(), |
| 135 | (6, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(6)) |
| 136 | ); |
| 137 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 138 | dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(3).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]size_hint().(), |
| 139 | (4, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4)) |
| 140 | ); |
| 141 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 142 | dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(4).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]size_hint().(), |
| 143 | (3, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)) |
| 144 | ); |
| 145 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 146 | dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(5).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]size_hint().(), |
| 147 | (3, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3)) |
| 148 | ); |
| 149 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 150 | dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(6).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]size_hint().(), |
| 151 | (2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)) |
| 152 | ); |
| 153 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 154 | dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(7).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]size_hint().(), |
| 155 | (2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)) |
| 156 | ); |
| 157 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 158 | dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(8).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]size_hint().(), |
| 159 | (2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)) |
| 160 | ); |
| 161 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 162 | dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(9).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]size_hint().(), |
| 163 | (2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)) |
| 164 | ); |
| 165 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 166 | dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(10).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]size_hint().(), |
| 167 | (2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)) |
| 168 | ); |
| 169 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 170 | dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(11).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]size_hint().(), |
| 171 | (2, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2)) |
| 172 | ); |
| 173 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 174 | dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_chunksrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]into_chunks().(12).size_hintrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[ChunksMut][Iterator]size_hint().(), |
| 175 | (1, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1)) |
| 176 | ); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | // |
| 181 | // DivBufShared methods |
| 182 | // |
| 183 | mod divbufsharedrust-analyzer cargo divbuf 0.4.1 divbufshared/ { |
| 184 | use superrust-analyzer cargo divbuf 0.4.1 crate/::*; |
| 185 | |
| 186 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 187 | pub fn cap_and_lenrust-analyzer cargo divbuf 0.4.1 divbufshared/cap_and_len().() { |
| 188 | let mut v = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<u8>::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(64); |
| 189 | v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(0); |
| 190 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(v); |
| 191 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbs.capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]capacity().(), 64); |
| 192 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbs.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]len().(), 1); |
| 193 | } |
| 194 | |
| 195 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 196 | pub fn fmtrust-analyzer cargo divbuf 0.4.1 divbufshared/fmt().() { |
| 197 | let v = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<u8>::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(64); |
| 198 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(v); |
| 199 | let output = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", &dbs); |
| 200 | let expected = "DivBufShared { inner: Inner { vec: [], accessors: 0, \ |
| 201 | sharers: 1 } }"; |
| 202 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(output, expected); |
| 203 | } |
| 204 | |
| 205 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 206 | pub fn from_slicerust-analyzer cargo divbuf 0.4.1 divbufshared/from_slice().() { |
| 207 | let s = b"abcdefg"; |
| 208 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<&'a [u8]>`]from().(&s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 209 | let mut dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 210 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm, s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 211 | // dbs should've been copy constructed, so we can mutate it without changing |
| 212 | // the original slice |
| 213 | dbm[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(). = b'A'; |
| 214 | assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(dbm, s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 215 | } |
| 216 | |
| 217 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 218 | pub fn is_emptyrust-analyzer cargo divbuf 0.4.1 divbufshared/is_empty().() { |
| 219 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(4096).is_emptyrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]is_empty().()); |
| 220 | 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().DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]).is_emptyrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]is_empty().()); |
| 221 | } |
| 222 | |
| 223 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 224 | pub fn sendrust-analyzer cargo divbuf 0.4.1 divbufshared/send().() { |
| 225 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(4096); |
| 226 | 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 || { |
| 227 | let _ = dbs; |
| 228 | }) |
| 229 | .joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/join_handle/impl#[`JoinHandle<T>`]join().() |
| 230 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 231 | } |
| 232 | |
| 233 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 234 | pub fn syncrust-analyzer cargo divbuf 0.4.1 divbufshared/sync().() { |
| 235 | lazy_staticrust-analyzer cargo lazy_static 1.5.0 lazy_static!! { |
| 236 | pub static ref DBSrust-analyzer cargo divbuf 0.4.1 divbufshared/DBS#: DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared# = |
| 237 | DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; 4096]); |
| 238 | } |
| 239 | let r = &DBSrust-analyzer cargo divbuf 0.4.1 divbufshared/DBS.; |
| 240 | 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 || { |
| 241 | let _ = r; |
| 242 | }) |
| 243 | .joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/join_handle/impl#[`JoinHandle<T>`]join().() |
| 244 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 245 | } |
| 246 | |
| 247 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 248 | pub fn try_construst-analyzer cargo divbuf 0.4.1 divbufshared/try_const().() { |
| 249 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(4096); |
| 250 | // Create an initial DivBuf |
| 251 | let _db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 252 | // Creating a second is allowed, too |
| 253 | let _db1 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 254 | } |
| 255 | |
| 256 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 257 | pub fn try_const_after_try_mutrust-analyzer cargo divbuf 0.4.1 divbufshared/try_const_after_try_mut().() { |
| 258 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(4096); |
| 259 | // Create an initial DivBufMut |
| 260 | let _dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 261 | // Creating a DivBuf should fail, because there are writers |
| 262 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 263 | } |
| 264 | |
| 265 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 266 | pub fn try_mutrust-analyzer cargo divbuf 0.4.1 divbufshared/try_mut().() { |
| 267 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(4096); |
| 268 | // Create an initial DivBufMut |
| 269 | let _dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 270 | // Creating a second is not allowed |
| 271 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 272 | } |
| 273 | |
| 274 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 275 | pub fn try_mut_after_try_construst-analyzer cargo divbuf 0.4.1 divbufshared/try_mut_after_try_const().() { |
| 276 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(4096); |
| 277 | // Create an initial DivBuf |
| 278 | let _db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 279 | // Now creating a mutable buffer is not allowed |
| 280 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 281 | } |
| 282 | |
| 283 | #[cfg(feature = "experimental")] |
| 284 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 285 | pub fn uninitializedrust-analyzer cargo divbuf 0.4.1 divbufshared/uninitialized().() { |
| 286 | let cap = 4096; |
| 287 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::uninitializedrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]uninitialized().(cap); |
| 288 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbs.capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]capacity().(), cap); |
| 289 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbs.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]len().(), cap); |
| 290 | } |
| 291 | |
| 292 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 293 | pub fn to_vecrust-analyzer cargo divbuf 0.4.1 divbufshared/to_vec().() { |
| 294 | let v = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4]; |
| 295 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(v); |
| 296 | |
| 297 | { |
| 298 | let mut dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 299 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 300 | dbm[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(). = 5; |
| 301 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm, [5, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 302 | } |
| 303 | |
| 304 | let v2: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = dbs.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 305 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v2, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![5, 2, 3, 4]); |
| 306 | } |
| 307 | |
| 308 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 309 | pub fn to_vec_after_try_mutrust-analyzer cargo divbuf 0.4.1 divbufshared/to_vec_after_try_mut().() { |
| 310 | let v = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4]; |
| 311 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(v); |
| 312 | |
| 313 | let _dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 314 | let maybe_v: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, _> = dbs.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().(); |
| 315 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(maybe_v.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 316 | } |
| 317 | |
| 318 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 319 | pub fn to_vec_after_try_construst-analyzer cargo divbuf 0.4.1 divbufshared/to_vec_after_try_const().() { |
| 320 | let v = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4]; |
| 321 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(v); |
| 322 | |
| 323 | let _db = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 324 | let maybe_v: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, _> = dbs.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().(); |
| 325 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(maybe_v.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 326 | } |
| 327 | |
| 328 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 329 | pub fn to_vec_after_clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbufshared/to_vec_after_clone_inaccessible().() { |
| 330 | let v = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4]; |
| 331 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(v); |
| 332 | |
| 333 | let dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 334 | let _dbi = dbm.clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]clone_inaccessible().(); |
| 335 | droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(dbm); |
| 336 | |
| 337 | let maybe_v: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, _> = dbs.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().(); |
| 338 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(maybe_v.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | // |
| 343 | // DivBuf methods |
| 344 | // |
| 345 | mod divbuf_rust-analyzer cargo divbuf 0.4.1 divbuf_/ { |
| 346 | use superrust-analyzer cargo divbuf 0.4.1 crate/::*; |
| 347 | |
| 348 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 349 | pub fn as_refrust-analyzer cargo divbuf 0.4.1 divbuf_/as_ref().() { |
| 350 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 351 | let db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 352 | let s: &[u8] = db0.as_refrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf][`AsRef<[u8]>`]as_ref().(); |
| 353 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, &[1, 2, 3]); |
| 354 | } |
| 355 | |
| 356 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 357 | pub fn as_ref_emptyrust-analyzer cargo divbuf 0.4.1 divbuf_/as_ref_empty().() { |
| 358 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]); |
| 359 | let db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 360 | let s: &[u8] = db0.as_refrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf][`AsRef<[u8]>`]as_ref().(); |
| 361 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, &[]); |
| 362 | } |
| 363 | |
| 364 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 365 | pub fn borrowrust-analyzer cargo divbuf 0.4.1 divbuf_/borrow().() { |
| 366 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 367 | let db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 368 | let s: &[u8] = db0.borrowrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf][`Borrow<[u8]>`]borrow().(); |
| 369 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, &[1, 2, 3]); |
| 370 | } |
| 371 | |
| 372 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 373 | pub fn clonerust-analyzer cargo divbuf 0.4.1 divbuf_/clone().() { |
| 374 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 375 | let db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 376 | let mut db1 = db0.clonerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf][Clone]clone().(); |
| 377 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0, db1); |
| 378 | // We should be able to modify one DivBuf without affecting the other |
| 379 | db1.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]split_off().(1); |
| 380 | assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(db0, db1); |
| 381 | } |
| 382 | |
| 383 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 384 | pub fn clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf_/clone_inaccessible().() { |
| 385 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 386 | let dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 387 | let _dbi: DivBufInaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/DivBufInaccessible# = dbm.clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]clone_inaccessible().(); |
| 388 | } |
| 389 | |
| 390 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 391 | pub fn derefrust-analyzer cargo divbuf 0.4.1 divbuf_/deref().() { |
| 392 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 393 | let db = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 394 | let slice: &[u8] = &db; |
| 395 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(slice, &[1, 2, 3]); |
| 396 | } |
| 397 | |
| 398 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 399 | pub fn deref_emptyrust-analyzer cargo divbuf 0.4.1 divbuf_/deref_empty().() { |
| 400 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]); |
| 401 | let db = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 402 | let slice: &[u8] = &db; |
| 403 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(slice, &[]); |
| 404 | } |
| 405 | |
| 406 | // A DivBuf should be able to own its storage, and will free it on last drop |
| 407 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 408 | pub fn drop_lastrust-analyzer cargo divbuf 0.4.1 divbuf_/drop_last().() { |
| 409 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 410 | let _db0 = dbs0.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 411 | droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(dbs0); |
| 412 | } |
| 413 | |
| 414 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 415 | pub fn eqrust-analyzer cargo divbuf 0.4.1 divbuf_/eq().() { |
| 416 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 417 | let dbs1 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 418 | let dbs2 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2]); |
| 419 | let db0 = dbs0.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 420 | let db1 = dbs1.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 421 | let db2 = dbs2.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 422 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0, db1); |
| 423 | assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(db0, db2); |
| 424 | } |
| 425 | |
| 426 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 427 | pub fn from_divbufmutrust-analyzer cargo divbuf 0.4.1 divbuf_/from_divbufmut().() { |
| 428 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 429 | let dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 430 | let _db = DivBufrust-analyzer cargo divbuf 0.4.1 divbuf/DivBuf#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf][`From<DivBufMut>`]from().(dbm); |
| 431 | } |
| 432 | |
| 433 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 434 | pub fn is_emptyrust-analyzer cargo divbuf 0.4.1 divbuf_/is_empty().() { |
| 435 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(64); |
| 436 | let db0 = dbs0.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 437 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(db0.is_emptyrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]is_empty().()); |
| 438 | |
| 439 | let dbs1 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1]); |
| 440 | let db1 = dbs1.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 441 | 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().db1.is_emptyrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]is_empty().()); |
| 442 | } |
| 443 | |
| 444 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 445 | pub fn hashrust-analyzer cargo divbuf 0.4.1 divbuf_/hash().() { |
| 446 | let v = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]; |
| 447 | let expected = simple_hashrust-analyzer cargo divbuf 0.4.1 simple_hash().(&v); |
| 448 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(v); |
| 449 | let db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 450 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(simple_hashrust-analyzer cargo divbuf 0.4.1 simple_hash().(&db0), expected); |
| 451 | } |
| 452 | |
| 453 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 454 | pub fn ordrust-analyzer cargo divbuf 0.4.1 divbuf_/ord().() { |
| 455 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 1, 0, 2]); |
| 456 | let db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().slice_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice_to().(2); |
| 457 | let db1 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().slice_fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice_from().(2); |
| 458 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0.cmprust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf][Ord]cmp().(&db1), Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Lessrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Less#); |
| 459 | } |
| 460 | |
| 461 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 462 | pub fn partial_ordrust-analyzer cargo divbuf 0.4.1 divbuf_/partial_ord().() { |
| 463 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 1, 0, 2]); |
| 464 | let db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().slice_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice_to().(2); |
| 465 | let db1 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().slice_fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice_from().(2); |
| 466 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(db0 <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). db1); |
| 467 | } |
| 468 | |
| 469 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 470 | pub fn sendrust-analyzer cargo divbuf 0.4.1 divbuf_/send().() { |
| 471 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(4096); |
| 472 | let db = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 473 | 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 || { |
| 474 | let _ = db; |
| 475 | }) |
| 476 | .joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/join_handle/impl#[`JoinHandle<T>`]join().() |
| 477 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 478 | } |
| 479 | |
| 480 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 481 | pub fn syncrust-analyzer cargo divbuf 0.4.1 divbuf_/sync().() { |
| 482 | lazy_staticrust-analyzer cargo lazy_static 1.5.0 lazy_static!! { |
| 483 | pub static ref DBSrust-analyzer cargo divbuf 0.4.1 divbuf_/DBS#: DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared# = |
| 484 | DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; 4096]); |
| 485 | pub static ref DBrust-analyzer cargo divbuf 0.4.1 divbuf_/DB#: DivBufrust-analyzer cargo divbuf 0.4.1 divbuf/DivBuf# = DBSrust-analyzer cargo divbuf 0.4.1 divbuf_/DBS..try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 486 | } |
| 487 | let r = &DBrust-analyzer cargo divbuf 0.4.1 divbuf_/DB.; |
| 488 | 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 || { |
| 489 | let _ = r; |
| 490 | }) |
| 491 | .joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/join_handle/impl#[`JoinHandle<T>`]join().() |
| 492 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 493 | } |
| 494 | |
| 495 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 496 | pub fn slicerust-analyzer cargo divbuf 0.4.1 divbuf_/slice().() { |
| 497 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 498 | let db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 499 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0.slicerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice().(0, 0), [][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 500 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0.slicerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice().(1, 5), [2, 3, 4, 5][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 501 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0.slicerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice().(1, 1), [][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 502 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0.slicerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice().(0, 6), db0); |
| 503 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0, [1, 2, 3, 4, 5, 6][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 504 | } |
| 505 | |
| 506 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 507 | #[should_panic(expected = "begin <= end")] |
| 508 | pub fn slice_backwardsrust-analyzer cargo divbuf 0.4.1 divbuf_/slice_backwards().() { |
| 509 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 510 | let db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 511 | db0.slicerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice().(1, 0); |
| 512 | } |
| 513 | |
| 514 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 515 | #[should_panic(expected = "end <= self.len")] |
| 516 | pub fn slice_after_endrust-analyzer cargo divbuf 0.4.1 divbuf_/slice_after_end().() { |
| 517 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 518 | let db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 519 | db0.slicerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice().(3, 7); |
| 520 | } |
| 521 | |
| 522 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 523 | pub fn slice_fromrust-analyzer cargo divbuf 0.4.1 divbuf_/slice_from().() { |
| 524 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 525 | let db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 526 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0.slice_fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice_from().(0), db0); |
| 527 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0.slice_fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice_from().(3), [4, 5, 6][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 528 | } |
| 529 | |
| 530 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 531 | pub fn slice_torust-analyzer cargo divbuf 0.4.1 divbuf_/slice_to().() { |
| 532 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 533 | let db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 534 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0.slice_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice_to().(6), db0); |
| 535 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0.slice_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice_to().(3), [1, 2, 3][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 536 | } |
| 537 | |
| 538 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 539 | pub fn split_offrust-analyzer cargo divbuf 0.4.1 divbuf_/split_off().() { |
| 540 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 541 | let mut db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 542 | // split in the middle |
| 543 | let db_mid = db0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]split_off().(4); |
| 544 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 545 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]len().(), 4); |
| 546 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db_mid, [5, 6][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 547 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db_mid.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]len().(), 2); |
| 548 | // split at the beginning |
| 549 | let mut db_begin = db0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]split_off().(0); |
| 550 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0, [][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 551 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db_begin, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 552 | // split at the end |
| 553 | let db_end = db_begin.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]split_off().(4); |
| 554 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db_begin, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 555 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db_end, [][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 556 | } |
| 557 | |
| 558 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 559 | #[should_panic(expected = "Can't split past the end")] |
| 560 | pub fn split_off_past_the_endrust-analyzer cargo divbuf 0.4.1 divbuf_/split_off_past_the_end().() { |
| 561 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 562 | let mut db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 563 | db0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]split_off().(7); |
| 564 | } |
| 565 | |
| 566 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 567 | pub fn split_torust-analyzer cargo divbuf 0.4.1 divbuf_/split_to().() { |
| 568 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 569 | let mut db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 570 | // split in the middle |
| 571 | let mut db_left = db0.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]split_to().(4); |
| 572 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db_left, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 573 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db_left.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]len().(), 4); |
| 574 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0, [5, 6][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 575 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]len().(), 2); |
| 576 | // split at the beginning |
| 577 | let db_begin = db_left.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]split_to().(0); |
| 578 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db_begin, [][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 579 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db_left, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 580 | // split at the end |
| 581 | let db_mid = db_left.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]split_to().(4); |
| 582 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db_mid, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 583 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db_left, [][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 584 | } |
| 585 | |
| 586 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 587 | #[should_panic(expected = "Can't split past the end")] |
| 588 | pub fn split_to_past_the_endrust-analyzer cargo divbuf 0.4.1 divbuf_/split_to_past_the_end().() { |
| 589 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 590 | let mut db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 591 | db0.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]split_to().(7); |
| 592 | } |
| 593 | |
| 594 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 595 | pub fn try_mutrust-analyzer cargo divbuf 0.4.1 divbuf_/try_mut().() { |
| 596 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(64); |
| 597 | let mut db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 598 | db0 = { |
| 599 | let db1 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 600 | // When multiple DivBufs are active, none can be upgraded |
| 601 | let db2 = db0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]try_mut().(); |
| 602 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(db2.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 603 | let db3 = db1.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]try_mut().(); |
| 604 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(db3.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 605 | db2.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().() |
| 606 | }; |
| 607 | // A single DivBuf alone can be upgraded |
| 608 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(db0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]try_mut().().is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 609 | } |
| 610 | |
| 611 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 612 | pub fn unsplitrust-analyzer cargo divbuf 0.4.1 divbuf_/unsplit().() { |
| 613 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 614 | let mut db0 = dbs0.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 615 | { |
| 616 | // split in the middle |
| 617 | let db_mid = db0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]split_off().(4); |
| 618 | // put it back together |
| 619 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(db0.unsplitrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]unsplit().(db_mid).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 620 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db0, [1, 2, 3, 4, 5, 6][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 621 | } |
| 622 | |
| 623 | { |
| 624 | // unsplit should fail for noncontiguous DivBufs |
| 625 | let mut db_begin = db0.slice_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice_to().(2); |
| 626 | let db_end = db0.slice_fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice_from().(4); |
| 627 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(db_begin.unsplitrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]unsplit().(db_end).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 628 | } |
| 629 | |
| 630 | { |
| 631 | // unsplit should fail for overlapping DivBufs |
| 632 | let mut db_begin = db0.slice_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice_to().(4); |
| 633 | let db_end = db0.slice_fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice_from().(2); |
| 634 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(db_begin.unsplitrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]unsplit().(db_end).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 635 | } |
| 636 | |
| 637 | { |
| 638 | // unsplit should fail for unrelated DivBufs |
| 639 | let dbs1 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![7, 8, 9]); |
| 640 | let mut db_end = db0.slice_fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]slice_from().(4); |
| 641 | let db_unrelated = dbs1.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 642 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(db_end.unsplitrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]unsplit().(db_unrelated).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 643 | } |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | mod divbuf_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/ { |
| 648 | use superrust-analyzer cargo divbuf 0.4.1 crate/::*; |
| 649 | |
| 650 | /// DivBufInaccessible's superpower is clone. |
| 651 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 652 | #[allow(clippy::redundant_clone)] |
| 653 | pub fn clonerust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/clone().() { |
| 654 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 655 | let db0 = dbs0.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 656 | let dbi0 = db0.clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]clone_inaccessible().(); |
| 657 | let _dbi1 = dbi0.clonerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufInaccessible][Clone]clone().(); |
| 658 | } |
| 659 | |
| 660 | // A DivBufInaccessible should be able to own its storage, and will free it |
| 661 | // on last drop. |
| 662 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 663 | pub fn drop_lastrust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/drop_last().() { |
| 664 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 665 | let db0 = dbs0.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 666 | let _dbi = db0.clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]clone_inaccessible().(); |
| 667 | droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(db0); |
| 668 | droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(dbs0); |
| 669 | } |
| 670 | |
| 671 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 672 | pub fn sendrust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/send().() { |
| 673 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(4096); |
| 674 | let db = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 675 | let dbi = db.clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]clone_inaccessible().(); |
| 676 | 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 || { |
| 677 | let _ = dbi; |
| 678 | }) |
| 679 | .joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/join_handle/impl#[`JoinHandle<T>`]join().() |
| 680 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 681 | } |
| 682 | |
| 683 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 684 | pub fn syncrust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/sync().() { |
| 685 | lazy_staticrust-analyzer cargo lazy_static 1.5.0 lazy_static!! { |
| 686 | pub static ref DBSrust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/DBS#: DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared# = |
| 687 | DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; 4096]); |
| 688 | pub static ref DBrust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/DB#: DivBufrust-analyzer cargo divbuf 0.4.1 divbuf/DivBuf# = DBSrust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/DBS..try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 689 | pub static ref DBIrust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/DBI#: DivBufInaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/DivBufInaccessible# = DBrust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/DB..clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]clone_inaccessible().(); |
| 690 | } |
| 691 | let r = &DBIrust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/DBI.; |
| 692 | 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 || { |
| 693 | let _ = r; |
| 694 | }) |
| 695 | .joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/join_handle/impl#[`JoinHandle<T>`]join().() |
| 696 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 697 | } |
| 698 | |
| 699 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 700 | pub fn try_const_failurerust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/try_const_failure().() { |
| 701 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 702 | let dbm = dbs0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 703 | let dbi = dbm.clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]clone_inaccessible().(); |
| 704 | dbi.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufInaccessible]try_const().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 705 | } |
| 706 | |
| 707 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 708 | pub fn try_const_successrust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/try_const_success().() { |
| 709 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 710 | let db0 = dbs0.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 711 | let dbi = db0.clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]clone_inaccessible().(); |
| 712 | dbi.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufInaccessible]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 713 | } |
| 714 | |
| 715 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 716 | pub fn try_mut_failurerust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/try_mut_failure().() { |
| 717 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 718 | let db = dbs0.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 719 | let dbi = db.clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]clone_inaccessible().(); |
| 720 | dbi.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufInaccessible]try_mut().().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 721 | } |
| 722 | |
| 723 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 724 | pub fn try_mut_successrust-analyzer cargo divbuf 0.4.1 divbuf_inaccessible/try_mut_success().() { |
| 725 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 726 | let db0 = dbs0.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 727 | let dbi = db0.clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]clone_inaccessible().(); |
| 728 | droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(db0); |
| 729 | dbi.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufInaccessible]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 730 | } |
| 731 | } |
| 732 | |
| 733 | // |
| 734 | // DivBufMut methods |
| 735 | // |
| 736 | mod divbuf_mutrust-analyzer cargo divbuf 0.4.1 divbuf_mut/ { |
| 737 | use superrust-analyzer cargo divbuf 0.4.1 crate/::*; |
| 738 | |
| 739 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 740 | pub fn as_refrust-analyzer cargo divbuf 0.4.1 divbuf_mut/as_ref().() { |
| 741 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 742 | let dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 743 | let s: &[u8] = dbm0.as_refrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][`AsRef<[u8]>`]as_ref().(); |
| 744 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, &[1, 2, 3]); |
| 745 | } |
| 746 | |
| 747 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 748 | pub fn as_ref_emptyrust-analyzer cargo divbuf 0.4.1 divbuf_mut/as_ref_empty().() { |
| 749 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]); |
| 750 | let dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 751 | let s: &[u8] = dbm0.as_refrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][`AsRef<[u8]>`]as_ref().(); |
| 752 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, &[]); |
| 753 | } |
| 754 | |
| 755 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 756 | pub fn borrowrust-analyzer cargo divbuf 0.4.1 divbuf_mut/borrow().() { |
| 757 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 758 | let dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 759 | let s: &[u8] = dbm0.borrowrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][`Borrow<[u8]>`]borrow().(); |
| 760 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, &[1, 2, 3]); |
| 761 | } |
| 762 | |
| 763 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 764 | pub fn borrowmutrust-analyzer cargo divbuf 0.4.1 divbuf_mut/borrowmut().() { |
| 765 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 766 | { |
| 767 | let mut dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 768 | let s: &mut [u8] = dbm0.borrow_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][`BorrowMut<[u8]>`]borrow_mut().(); |
| 769 | s[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(). = 9; |
| 770 | } |
| 771 | let db0 = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 772 | let slice: &[u8] = &db0; |
| 773 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(slice, &[9, 2, 3]); |
| 774 | } |
| 775 | |
| 776 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 777 | pub fn clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf_mut/clone_inaccessible().() { |
| 778 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 779 | let db = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 780 | let _dbi: DivBufInaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/DivBufInaccessible# = db.clone_inaccessiblerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBuf]clone_inaccessible().(); |
| 781 | } |
| 782 | |
| 783 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 784 | pub fn derefrust-analyzer cargo divbuf 0.4.1 divbuf_mut/deref().() { |
| 785 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 786 | let dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 787 | let slice: &[u8] = &dbm; |
| 788 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(slice, &[1, 2, 3]); |
| 789 | } |
| 790 | |
| 791 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 792 | pub fn deref_emptyrust-analyzer cargo divbuf 0.4.1 divbuf_mut/deref_empty().() { |
| 793 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]); |
| 794 | let dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 795 | let slice: &[u8] = &dbm; |
| 796 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(slice, &[]); |
| 797 | } |
| 798 | |
| 799 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 800 | pub fn derefmutrust-analyzer cargo divbuf 0.4.1 divbuf_mut/derefmut().() { |
| 801 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 802 | let mut dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 803 | // Unlike DivBuf, we _can_ update DivBufMuts randomly |
| 804 | dbm[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(). = 9; |
| 805 | let slice: &mut [u8] = &mut dbm; |
| 806 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(slice, &[9, 2, 3]); |
| 807 | } |
| 808 | |
| 809 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 810 | pub fn derefmut_emptyrust-analyzer cargo divbuf 0.4.1 divbuf_mut/derefmut_empty().() { |
| 811 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]); |
| 812 | let mut dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 813 | let slice: &mut [u8] = &mut dbm; |
| 814 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(slice, &[]); |
| 815 | } |
| 816 | |
| 817 | // A DivBufMut should be able to own its storage, and will free it on last drop |
| 818 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 819 | pub fn drop_lastrust-analyzer cargo divbuf 0.4.1 divbuf_mut/drop_last().() { |
| 820 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 821 | let _dbm0 = dbs0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 822 | droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(dbs0); |
| 823 | } |
| 824 | |
| 825 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 826 | pub fn eqrust-analyzer cargo divbuf 0.4.1 divbuf_mut/eq().() { |
| 827 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 828 | let dbs1 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 829 | let dbs2 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2]); |
| 830 | let dbm0 = dbs0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 831 | let dbm1 = dbs1.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 832 | let dbm2 = dbs2.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 833 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm0, dbm1); |
| 834 | assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(dbm0, dbm2); |
| 835 | } |
| 836 | |
| 837 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 838 | pub fn extendrust-analyzer cargo divbuf 0.4.1 divbuf_mut/extend().() { |
| 839 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 840 | { |
| 841 | let mut dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 842 | dbm.extendrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][`Extend<&'a u8>`]extend().([4, 5, 6].iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()); |
| 843 | } |
| 844 | // verify that dbs.inner.vec was extended |
| 845 | let db = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 846 | let slice: &[u8] = &db; |
| 847 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(slice, &[1, 2, 3, 4, 5, 6]); |
| 848 | } |
| 849 | |
| 850 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 851 | #[should_panic(expected = "extend into the middle of a buffer")] |
| 852 | pub fn extend_from_the_middlerust-analyzer cargo divbuf 0.4.1 divbuf_mut/extend_from_the_middle().() { |
| 853 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 854 | let mut dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 855 | let mut dbm_begin = dbm.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_to().(3); |
| 856 | dbm_begin.extendrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][`Extend<&'a u8>`]extend().([7, 8, 9].iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()); |
| 857 | } |
| 858 | |
| 859 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 860 | pub fn freezerust-analyzer cargo divbuf 0.4.1 divbuf_mut/freeze().() { |
| 861 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6, 7, 8]); |
| 862 | { |
| 863 | // Simplest case: freeze the entire buffer |
| 864 | let dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 865 | let _: DivBufrust-analyzer cargo divbuf 0.4.1 divbuf/DivBuf# = dbm.freezerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]freeze().(); |
| 866 | } |
| 867 | { |
| 868 | // Freeze a buffer in the presence of other readers && writers |
| 869 | let mut dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 870 | let right_half = dbm.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_off().(4); |
| 871 | let _db_right_half = right_half.freezerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]freeze().(); |
| 872 | let left_quarter = dbm.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_to().(2); |
| 873 | let _db_left_quarter = left_quarter.freezerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]freeze().(); |
| 874 | // We should still be able to mutate from the remaining DivBufMut |
| 875 | dbm[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(). = 33; |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 880 | pub fn hashrust-analyzer cargo divbuf 0.4.1 divbuf_mut/hash().() { |
| 881 | let v = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]; |
| 882 | let expected = simple_hashrust-analyzer cargo divbuf 0.4.1 simple_hash().(&v); |
| 883 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(v); |
| 884 | let dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 885 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(simple_hashrust-analyzer cargo divbuf 0.4.1 simple_hash().(&dbm0), expected); |
| 886 | } |
| 887 | |
| 888 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 889 | pub fn is_emptyrust-analyzer cargo divbuf 0.4.1 divbuf_mut/is_empty().() { |
| 890 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(64); |
| 891 | let mut dbm0 = dbs0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 892 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm0.is_emptyrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]is_empty().()); |
| 893 | |
| 894 | dbm0.extendrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][`Extend<&'a u8>`]extend().([4, 5, 6].iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()); |
| 895 | 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().dbm0.is_emptyrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]is_empty().()); |
| 896 | } |
| 897 | |
| 898 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 899 | pub fn ordrust-analyzer cargo divbuf 0.4.1 divbuf_mut/ord().() { |
| 900 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 1, 0, 2]); |
| 901 | let mut dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 902 | let dbm1 = dbm0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_off().(2); |
| 903 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm0.cmprust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][Ord]cmp().(&dbm1), Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Lessrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Less#); |
| 904 | } |
| 905 | |
| 906 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 907 | pub fn partial_ordrust-analyzer cargo divbuf 0.4.1 divbuf_mut/partial_ord().() { |
| 908 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 1, 0, 2]); |
| 909 | let mut dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 910 | let dbm1 = dbm0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_off().(2); |
| 911 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm0 <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). dbm1); |
| 912 | } |
| 913 | |
| 914 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 915 | pub fn reserverust-analyzer cargo divbuf 0.4.1 divbuf_mut/reserve().() { |
| 916 | let v = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<u8>::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(64); |
| 917 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(v); |
| 918 | let mut dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 919 | dbm.reserverust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]reserve().(128); |
| 920 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbs.capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]capacity().(), 128); |
| 921 | } |
| 922 | |
| 923 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 924 | #[should_panic(expected = "reserve from the middle of a buffer")] |
| 925 | pub fn reserve_from_the_middlerust-analyzer cargo divbuf 0.4.1 divbuf_mut/reserve_from_the_middle().() { |
| 926 | let v = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]; |
| 927 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(v); |
| 928 | let mut dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 929 | let mut left_half = dbm.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_to().(3); |
| 930 | left_half.reserverust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]reserve().(128); |
| 931 | } |
| 932 | |
| 933 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 934 | pub fn sendrust-analyzer cargo divbuf 0.4.1 divbuf_mut/send().() { |
| 935 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(4096); |
| 936 | let dbm = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 937 | 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 || { |
| 938 | let _ = dbm; |
| 939 | }) |
| 940 | .joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/join_handle/impl#[`JoinHandle<T>`]join().() |
| 941 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 942 | } |
| 943 | |
| 944 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 945 | pub fn syncrust-analyzer cargo divbuf 0.4.1 divbuf_mut/sync().() { |
| 946 | lazy_staticrust-analyzer cargo lazy_static 1.5.0 lazy_static!! { |
| 947 | pub static ref DBSrust-analyzer cargo divbuf 0.4.1 divbuf_mut/DBS#: DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared# = |
| 948 | DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; 4096]); |
| 949 | pub static ref DBMrust-analyzer cargo divbuf 0.4.1 divbuf_mut/DBM#: DivBufMutrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufMut# = DBSrust-analyzer cargo divbuf 0.4.1 divbuf_mut/DBS..try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 950 | } |
| 951 | let r = &DBMrust-analyzer cargo divbuf 0.4.1 divbuf_mut/DBM.; |
| 952 | 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 || { |
| 953 | let _ = r; |
| 954 | }) |
| 955 | .joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/join_handle/impl#[`JoinHandle<T>`]join().() |
| 956 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 957 | } |
| 958 | |
| 959 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 960 | pub fn split_offrust-analyzer cargo divbuf 0.4.1 divbuf_mut/split_off().() { |
| 961 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 962 | let mut dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 963 | // split in the middle |
| 964 | let dbm_mid = dbm0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_off().(4); |
| 965 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm0, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 966 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm0.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]len().(), 4); |
| 967 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm_mid, [5, 6][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 968 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm_mid.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]len().(), 2); |
| 969 | // split at the beginning |
| 970 | let mut dbm_begin = dbm0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_off().(0); |
| 971 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm0, [][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 972 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm_begin, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 973 | // split at the end |
| 974 | let dbm_end = dbm_begin.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_off().(4); |
| 975 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm_begin, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 976 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm_end, [][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 977 | } |
| 978 | |
| 979 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 980 | #[should_panic(expected = "Can't split past the end")] |
| 981 | pub fn split_off_past_the_endrust-analyzer cargo divbuf 0.4.1 divbuf_mut/split_off_past_the_end().() { |
| 982 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 983 | let mut dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 984 | dbm0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_off().(7); |
| 985 | } |
| 986 | |
| 987 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 988 | pub fn split_torust-analyzer cargo divbuf 0.4.1 divbuf_mut/split_to().() { |
| 989 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 990 | let mut dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 991 | // split in the middle |
| 992 | let mut dbm_left = dbm0.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_to().(4); |
| 993 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm_left, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 994 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm_left.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]len().(), 4); |
| 995 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm0, [5, 6][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 996 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm0.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]len().(), 2); |
| 997 | // split at the beginning |
| 998 | let dbm_begin = dbm_left.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_to().(0); |
| 999 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm_begin, [][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 1000 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm_left, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 1001 | // split at the end |
| 1002 | let dbm_mid = dbm_left.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_to().(4); |
| 1003 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm_mid, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 1004 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm_left, [][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 1005 | } |
| 1006 | |
| 1007 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1008 | #[should_panic(expected = "Can't split past the end")] |
| 1009 | pub fn split_to_past_the_endrust-analyzer cargo divbuf 0.4.1 divbuf_mut/split_to_past_the_end().() { |
| 1010 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 1011 | let mut dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1012 | dbm0.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_to().(7); |
| 1013 | } |
| 1014 | |
| 1015 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1016 | pub fn try_extendrust-analyzer cargo divbuf 0.4.1 divbuf_mut/try_extend().() { |
| 1017 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3]); |
| 1018 | { |
| 1019 | let mut dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1020 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm0.try_extendrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]try_extend().([4, 5, 6].iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1021 | |
| 1022 | // Extending from the middle of the vec should fail |
| 1023 | let mut dbm1 = dbm0.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_to().(2); |
| 1024 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm1.try_extendrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]try_extend().([7, 8, 9].iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1025 | } |
| 1026 | |
| 1027 | // verify that dbs.inner.vec was extended the first time, but not the |
| 1028 | // second. |
| 1029 | let db = dbs.try_construst-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_const().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1030 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db, [1, 2, 3, 4, 5, 6][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 1031 | } |
| 1032 | |
| 1033 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1034 | pub fn try_resizerust-analyzer cargo divbuf 0.4.1 divbuf_mut/try_resize().() { |
| 1035 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 1036 | { |
| 1037 | let mut dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1038 | // First, resize past the end of the vector |
| 1039 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm0.try_resizerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]try_resize().(7, 42).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1040 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm0.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]len().(), 7); |
| 1041 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&dbm0[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &[1, 2, 3, 4, 5, 6, 42][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 1042 | // Then, do a truncation |
| 1043 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm0.try_resizerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]try_resize().(4, 42).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1044 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm0, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 1045 | // Check that the shared vector was truncated, too |
| 1046 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbs.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]len().(), 4); |
| 1047 | // A resize of a non-terminal DivBufMut should fail |
| 1048 | let mut dbm1 = dbm0.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_to().(2); |
| 1049 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm1.try_resizerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]try_resize().(3, 42).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1050 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm1.try_resizerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]try_resize().(10, 42).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1051 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbs.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]len().(), 4); |
| 1052 | // Resizing a terminal DivBufMut should work, even if it doesn't start |
| 1053 | // at the vector's beginning |
| 1054 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm0.try_resizerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]try_resize().(5, 0).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1055 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&dbm0[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &[3, 4, 0, 0, 0][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 1056 | } |
| 1057 | } |
| 1058 | |
| 1059 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1060 | pub fn try_truncaterust-analyzer cargo divbuf 0.4.1 divbuf_mut/try_truncate().() { |
| 1061 | let dbs = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 1062 | { |
| 1063 | let mut dbm0 = dbs.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1064 | // First, truncate past the end of the vector |
| 1065 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm0.try_truncaterust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]try_truncate().(7).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1066 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm0.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]len().(), 6); |
| 1067 | // Then, do a normal truncation |
| 1068 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm0.try_truncaterust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]try_truncate().(4).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1069 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm0, [1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 1070 | // Check that the shared vector was truncated, too |
| 1071 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbs.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]len().(), 4); |
| 1072 | // A truncation of a non-terminal DivBufMut should fail |
| 1073 | let mut dbm1 = dbm0.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_to().(2); |
| 1074 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm1.try_truncaterust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]try_truncate().(3).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1075 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbs.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]len().(), 4); |
| 1076 | // Truncating a terminal DivBufMut should work, even if it doesn't start |
| 1077 | // at the vector's beginning |
| 1078 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm0.try_truncaterust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]try_truncate().(1).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1079 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbs.lenrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]len().(), 3); |
| 1080 | } |
| 1081 | } |
| 1082 | |
| 1083 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1084 | pub fn unsplitrust-analyzer cargo divbuf 0.4.1 divbuf_mut/unsplit().() { |
| 1085 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1, 2, 3, 4, 5, 6]); |
| 1086 | { |
| 1087 | let mut dbm0 = dbs0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1088 | // split in the middle |
| 1089 | let dbm_mid = dbm0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_off().(4); |
| 1090 | // put it back together |
| 1091 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm0.unsplitrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]unsplit().(dbm_mid).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1092 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dbm0, [1, 2, 3, 4, 5, 6][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 1093 | } |
| 1094 | |
| 1095 | { |
| 1096 | // unsplit should fail for noncontiguous DivBufMuts |
| 1097 | let mut dbm0 = dbs0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1098 | let mut dbm_begin = dbm0.split_torust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_to().(2); |
| 1099 | let dbm_end = dbm0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_off().(2); |
| 1100 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm_begin.unsplitrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]unsplit().(dbm_end).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1101 | } |
| 1102 | |
| 1103 | { |
| 1104 | // unsplit should fail for unrelated DivBufMuts |
| 1105 | let mut dbm0 = dbs0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1106 | let dbs1 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![7, 8, 9]); |
| 1107 | let mut dbm_end = dbm0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_off().(4); |
| 1108 | let dbm_unrelated = dbs1.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1109 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm_end.unsplitrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]unsplit().(dbm_unrelated).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1110 | } |
| 1111 | } |
| 1112 | |
| 1113 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1114 | pub fn writerust-analyzer cargo divbuf 0.4.1 divbuf_mut/write().() { |
| 1115 | const MSGrust-analyzer cargo divbuf 0.4.1 divbuf_mut/MSG.: &[u8] = b"ABCD"; |
| 1116 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(0); |
| 1117 | let mut dbm0 = dbs0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1118 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MSGrust-analyzer cargo divbuf 0.4.1 divbuf_mut/MSG..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), dbm0.writerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][Write]write().(MSGrust-analyzer cargo divbuf 0.4.1 divbuf_mut/MSG.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()); |
| 1119 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&dbm0[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &[65u8, 66u8, 67u8, 68u8][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().) |
| 1120 | } |
| 1121 | |
| 1122 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1123 | pub fn write_nonterminalrust-analyzer cargo divbuf 0.4.1 divbuf_mut/write_nonterminal().() { |
| 1124 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 1, 2, 3]); |
| 1125 | let mut dbm0 = dbs0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1126 | let _ = dbm0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_off().(2); |
| 1127 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm0.writerust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][Write]write().("ABCD".as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1128 | } |
| 1129 | |
| 1130 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1131 | pub fn write_allrust-analyzer cargo divbuf 0.4.1 divbuf_mut/write_all().() { |
| 1132 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(0); |
| 1133 | let mut dbm0 = dbs0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1134 | dbm0.write_allrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][Write]write_all().("ABCD".as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1135 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&dbm0[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &[65u8, 66u8, 67u8, 68u8][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().) |
| 1136 | } |
| 1137 | |
| 1138 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1139 | pub fn write_all_nonterminalrust-analyzer cargo divbuf 0.4.1 divbuf_mut/write_all_nonterminal().() { |
| 1140 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::fromrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared][`From<Vec<u8>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 1, 2, 3]); |
| 1141 | let mut dbm0 = dbs0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1142 | let _ = dbm0.split_offrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut]split_off().(2); |
| 1143 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dbm0.write_allrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][Write]write_all().("ABCD".as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1144 | } |
| 1145 | |
| 1146 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1147 | pub fn flushrust-analyzer cargo divbuf 0.4.1 divbuf_mut/flush().() { |
| 1148 | let dbs0 = DivBufSharedrust-analyzer cargo divbuf 0.4.1 divbuf/DivBufShared#::with_capacityrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]with_capacity().(0); |
| 1149 | let mut dbm0 = dbs0.try_mutrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufShared]try_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1150 | dbm0.write_allrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][Write]write_all().("ABCD".as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1151 | dbm0.flushrust-analyzer cargo divbuf 0.4.1 divbuf/impl#[DivBufMut][Write]flush().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1152 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&dbm0[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &[65u8, 66u8, 67u8, 68u8][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().) |
| 1153 | } |
| 1154 | } |