Debian Codegraph @

src/buffer/std_buf.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/, memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#};
2
3 use selfrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/::impl_rust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/::RawBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#;
4
5 pub struct StdBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf# {
6 bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#buf.: RawBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#,
7 posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos.: usize,
8 endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end.: usize,
9 }
10
11 impl StdBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf# {
12 pub fn with_capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]with_capacity().(cap: usize) -> Selfrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf] {
13 StdBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf# {
14 bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#buf.: RawBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]with_capacity().(cap),
15 posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos.: 0,
16 endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end.: 0,
17 }
18 }
19
20 pub fn capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]capacity().(&self) -> usize {
21 self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#buf..capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]capacity().()
22 }
23
24 pub fn lenrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]len().(&self) -> usize {
25 self.endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().self.posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos.
26 }
27
28 pub fn usable_spacerust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]usable_space().(&self) -> usize {
29 self.capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]capacity().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().self.endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end.
30 }
31
32 pub fn reserverust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]reserve().(&mut self, additional: usize) -> bool {
33 self.check_cursorsrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]check_cursors().();
34 let usable_space = self.usable_spacerust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]usable_space().();
35
36 // there's already enough space
37 if usable_space rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().additional {
38 return false;
39 }
40
41 // attempt to reserve additional capacity in-place
42 if self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#buf..reserve_in_placerust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]reserve_in_place().(additional rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().usable_space) {
43 return false;
44 }
45
46 // don't copy the contents of the buffer as they're irrelevant now
47 if self.posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().self.endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end. {
48 let capacity = self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#buf..capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]capacity().();
49 // free the existing memory
50 self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#buf. = RawBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]with_capacity().(0);
51 self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#buf. = RawBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]with_capacity().(capacity rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().additional);
52 return true;
53 }
54
55 self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#buf..reserverust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]reserve().(additional rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().usable_space)
56 }
57
58 pub fn make_roomrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]make_room().(&mut self) {
59 self.check_cursorsrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]check_cursors().();
60
61 // no room at the head of the buffer
62 if self.posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
63 return;
64 }
65
66 // simply move the bytes down to the beginning
67 let len = self.lenrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]len().();
68
69 let buf_slice = unsafe { self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#buf..as_mut_slicerust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]as_mut_slice().() };
70 buf_slice.copy_withinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_within().(self.posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().len, 0);
71
72 self.posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos. = 0;
73 self.endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end. = len;
74 }
75
76 #[inline]
77 pub fn bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]buf().(&self) -> &[u8] {
78 unsafe { &self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#buf..as_slicerust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]as_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). }
79 }
80
81 pub fn buf_mutrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]buf_mut().(&mut self) -> &mut [u8] {
82 unsafe { &mut self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#buf..as_mut_slicerust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]as_mut_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().self.posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). }
83 }
84
85 pub unsafe fn write_bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]write_buf().(&mut self) -> &mut [MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#<u8>] {
86 let slice: &mut [u8] = &mut self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#buf..as_mut_slicerust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]as_mut_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().self.endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().;
87 // SAFETY: &[T] and &[MaybeUninit<T>] have the same layout
88 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::transmuterust-analyzer cargo core https://github.com/rust-lang/rust/library/core intrinsics/transmute().(slice)
89 }
90
91 pub unsafe fn bytes_writtenrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]bytes_written().(&mut self, amt: usize) {
92 self.endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end. = cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(self.endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().amt, self.capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]capacity().());
93 }
94
95 pub fn consumerust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]consume().(&mut self, amt: usize) {
96 self.posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos. = cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(self.posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().amt, self.endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end.);
97 self.check_cursorsrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]check_cursors().();
98 }
99
100 pub fn check_cursorsrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl#[StdBuf]check_cursors().(&mut self) -> bool {
101 if self.posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().self.endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end. {
102 self.posrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#pos. = 0;
103 self.endrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/StdBuf#end. = 0;
104 true
105 } else {
106 false
107 }
108 }
109 }
110
111 mod impl_rust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/ {
112 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/;
113
114 pub struct RawBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf# {
115 bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#buf.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[u8]>,
116 }
117
118 impl RawBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf# {
119 pub fn with_capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]with_capacity().(capacity: usize) -> Selfrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf] {
120 let mut buf = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(capacity);
121 let true_cap = buf.capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]capacity().();
122
123 unsafe {
124 buf.set_lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]set_len().(true_cap);
125 }
126
127 RawBufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf# {
128 bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#buf.: buf.into_boxed_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]into_boxed_slice().(),
129 }
130 }
131
132 pub fn capacityrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]capacity().(&self) -> usize {
133 self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#buf..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()
134 }
135
136 pub fn reserverust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]reserve().(&mut self, additional: usize) -> bool {
137 let mut buf = memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/replace().(&mut self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#buf., Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().([])).into_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]into_vec().();
138
139 let old_ptr = self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#buf..as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().();
140
141 buf.reserve_exactrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]reserve_exact().(additional);
142
143 unsafe {
144 let new_cap = buf.capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]capacity().();
145 buf.set_lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]set_len().(new_cap);
146 }
147
148 self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#buf. = buf.into_boxed_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]into_boxed_slice().();
149
150 old_ptr rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/const_ptr/impl#[`*const T`][`PartialEq<Self>`]eq().self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#buf..as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().()
151 }
152
153 pub fn reserve_in_placerust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]reserve_in_place().(&mut self, _additional: usize) -> bool {
154 // `Vec` does not support this
155 false
156 }
157
158 #[inline]
159 pub unsafe fn as_slicerust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]as_slice().(&self) -> &[u8] {
160 &self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#buf.
161 }
162
163 pub unsafe fn as_mut_slicerust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/impl#[RawBuf]as_mut_slice().(&mut self) -> &mut [u8] {
164 &mut self.bufrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/impl_/RawBuf#buf.
165 }
166 }
167 }
168
169 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
170 fn read_into_fullrust-analyzer cargo buffer-redux 1.1.0 buffer/std_buf/read_into_full().() {
171 use craterust-analyzer cargo buffer-redux 1.1.0 crate/::Bufferrust-analyzer cargo buffer-redux 1.1.0 Buffer#;
172
173 let mut buffer = Bufferrust-analyzer cargo buffer-redux 1.1.0 Buffer#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 impl#[Buffer]with_capacity().(1);
174
175 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buffer.capacityrust-analyzer cargo buffer-redux 1.1.0 impl#[Buffer]capacity().(), 1);
176
177 let mut bytes = &[1u8, 2][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 ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().;
178
179 // Result<usize, io::Error> does not impl PartialEq
180 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buffer.read_fromrust-analyzer cargo buffer-redux 1.1.0 impl#[Buffer]read_from().(&mut bytes).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1);
181 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buffer.read_fromrust-analyzer cargo buffer-redux 1.1.0 impl#[Buffer]read_from().(&mut bytes).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0);
182 }