Debian Codegraph @

src/limitor.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/;
2 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/;
3
4 use superrust-analyzer cargo buffered-reader 1.4.1 crate/::*;
5
6 /// Limits the amount of data that can be read from a
7 /// `BufferedReader`.
8 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
9 pub struct Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#<T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C>, C: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#> {
10 limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit.: u64,
11 cookierust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#cookie.: C,
12 readerrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#reader.: T,
13 }
14
15 assert_send_and_syncrust-analyzer cargo buffered-reader 1.4.1 macros/assert_send_and_sync!!(Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#<T, C>
16 where T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C>,
17 C: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#);
18
19 impl<T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C>, C: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#<T, C> {
20 fn fmtrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
21 f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Limitor")
22 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("limit", &self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit.)
23 .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().()
24 }
25 }
26
27 impl<T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<()>> Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#<T, ()> {
28 /// Instantiates a new limitor.
29 ///
30 /// `reader` is the source to wrap. `limit` is the maximum number
31 /// of bytes that can be read from the source.
32 pub fn newrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, ()>`]new().(reader: T, limit: u64) -> Selfrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, ()>`] {
33 Selfrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, ()>`]::with_cookierust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`]with_cookie().(reader, limit, ())
34 }
35 }
36
37 impl<T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C>, C: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#> Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#<T, C> {
38 /// Like [`Self::new`], but sets a cookie.
39 ///
40 /// The cookie can be retrieved using the [`BufferedReader::cookie_ref`] and
41 /// [`BufferedReader::cookie_mut`] methods, and set using the [`BufferedReader::cookie_set`] method.
42 pub fn with_cookierust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`]with_cookie().(reader: T, limit: u64, cookie: C)
43 -> Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#<T, C> {
44 Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor# {
45 readerrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#reader.,
46 limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit.,
47 cookierust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#cookie.,
48 }
49 }
50 }
51
52 impl<T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C>, C: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#<T, C> {
53 fn readrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][Read]read().(&mut self, buf: &mut [u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<usize, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> {
54 let len = 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.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit., buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as u64) as usize;
55 let result = self.readerrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#reader..readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read().(&mut buf[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/range/Range#len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().);
56 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(amount) = result {
57 self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().amount as u64;
58 }
59 result
60 }
61 }
62
63 impl<T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C>, C: fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#> BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C> for Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#<T, C> {
64 fn bufferrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]buffer().(&self) -> &[u8] {
65 let buf = self.readerrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#reader..bufferrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#buffer().();
66 &buf[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/RangeTo#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().(buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(),
67 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().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::usizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core legacy_int_modules/usize/::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core legacy_int_modules/usize/MAX. as u64,
68 self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit.) as usize)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
69 }
70
71 /// Return the buffer. Ensure that it contains at least `amount`
72 /// bytes.
73 fn datarust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]data().(&mut self, amount: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&[u8], iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> {
74 let amount = 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().(amount as u64, self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit.) as usize;
75 let result = self.readerrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#reader..datarust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data().(amount);
76 match result {
77 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(buffer) =>
78 if buffer.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as u64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit. {
79 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit. as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
80 } else {
81 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(buffer)
82 },
83 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err),
84 }
85 }
86
87 fn consumerust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]consume().(&mut self, amount: usize) -> &[u8] {
88 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(amount as u64 <= self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit.);
89 self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().amount as u64;
90 let data = self.readerrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#reader..consumerust-analyzer cargo buffered-reader 1.4.1 BufferedReader#consume().(amount);
91 &data[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/RangeTo#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.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().amount as u64, data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as u64) as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
92 }
93
94 fn data_consumerust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]data_consume().(&mut self, amount: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&[u8], iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> {
95 let amount = 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().(amount as u64, self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit.) as usize;
96 let result = self.readerrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#reader..data_consumerust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_consume().(amount);
97 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(buffer) = result {
98 let amount = 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().(amount, buffer.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
99 self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().amount as u64;
100 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
101 ..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#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().(buffer.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as u64, self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().amount as u64) as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
102 }
103 result
104 }
105
106 fn data_consume_hardrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]data_consume_hard().(&mut self, amount: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&[u8], iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> {
107 if amount as u64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit. {
108 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::UnexpectedEofrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#UnexpectedEof#, "EOF"));
109 }
110 let result = self.readerrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#reader..data_consume_hardrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_consume_hard().(amount);
111 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(buffer) = result {
112 let amount = 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().(amount, buffer.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
113 self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`SubAssign<Self>`]sub_assign().amount as u64;
114 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
115 ..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#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().(buffer.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as u64, self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().amount as u64) as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
116 }
117 result
118 }
119
120 fn consummatedrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]consummated().(&mut self) -> bool {
121 self.limitrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#limit. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().0
122 }
123
124 fn get_mutrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]get_mut().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut dyn BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C>> {
125 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&mut self.readerrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#reader.)
126 }
127
128 fn get_refrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]get_ref().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&dyn BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C>> {
129 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&self.readerrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#reader.)
130 }
131
132 fn into_innerrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]into_inner().<'b>(self: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Selfrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]>) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C> + 'b>>
133 where Selfrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]: 'b {
134 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.readerrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#reader..into_boxedrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#into_boxed().())
135 }
136
137 fn cookie_setrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]cookie_set().(&mut self, cookie: C) -> C {
138 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/;
139
140 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.cookierust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#cookie., cookie)
141 }
142
143 fn cookie_refrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]cookie_ref().(&self) -> &C {
144 &self.cookierust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#cookie.
145 }
146
147 fn cookie_mutrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]cookie_mut().(&mut self) -> &mut C {
148 &mut self.cookierust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#cookie.
149 }
150 }
151
152 #[cfg(test)]
153 mod testrust-analyzer cargo buffered-reader 1.4.1 limitor/test/ {
154 use superrust-analyzer cargo buffered-reader 1.4.1 limitor/::*;
155
156 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
157 fn buffered_reader_limitor_testrust-analyzer cargo buffered-reader 1.4.1 limitor/test/buffered_reader_limitor_test().() {
158 let data : &[u8] = b"01234567890123456789";
159
160 /* Add a single limitor. */
161 {
162 let mut bio : Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<()>>
163 = 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().(Memoryrust-analyzer cargo buffered-reader 1.4.1 memory/Memory#::newrust-analyzer cargo buffered-reader 1.4.1 memory/impl#[`Memory<'a, ()>`]new().(data));
164
165 bio = {
166 let mut bio2 = 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().(Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#::newrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, ()>`]new().(bio, 5));
167 {
168 let result = bio2.datarust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]data().(5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
169 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 5);
170 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result, &b"01234"[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().);
171 }
172 bio2.consumerust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]consume().(5);
173 {
174 let result = bio2.datarust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]data().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
175 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0);
176 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result, &b""[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().);
177 }
178
179 bio2.into_innerrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]into_inner().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
180 };
181
182 {
183 {
184 let result = bio.datarust-analyzer cargo buffered-reader 1.4.1 impl#[`Box<dyn BufferedReader<C> + 'a>`][`BufferedReader<C>`]data().(15).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
185 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 15);
186 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result, &b"567890123456789"[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().);
187 }
188 bio.consumerust-analyzer cargo buffered-reader 1.4.1 impl#[`Box<dyn BufferedReader<C> + 'a>`][`BufferedReader<C>`]consume().(15);
189 {
190 let result = bio.datarust-analyzer cargo buffered-reader 1.4.1 impl#[`Box<dyn BufferedReader<C> + 'a>`][`BufferedReader<C>`]data().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
191 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0);
192 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result, &b""[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().);
193 }
194 }
195 }
196
197 /* Try with two limitors where the first one imposes the real
198 * limit. */
199 {
200 let mut bio : Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<()>>
201 = 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().(Memoryrust-analyzer cargo buffered-reader 1.4.1 memory/Memory#::newrust-analyzer cargo buffered-reader 1.4.1 memory/impl#[`Memory<'a, ()>`]new().(data));
202
203 bio = {
204 let bio2 : Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<()>>
205 = 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().(Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#::newrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, ()>`]new().(bio, 5));
206 // We limit to 15 bytes, but bio2 will still limit us to 5
207 // bytes.
208 let mut bio3 : Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<()>>
209 = 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().(Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#::newrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, ()>`]new().(bio2, 15));
210 {
211 let result = bio3.datarust-analyzer cargo buffered-reader 1.4.1 impl#[`Box<dyn BufferedReader<C> + 'a>`][`BufferedReader<C>`]data().(100).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
212 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 5);
213 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result, &b"01234"[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().);
214 }
215 bio3.consumerust-analyzer cargo buffered-reader 1.4.1 impl#[`Box<dyn BufferedReader<C> + 'a>`][`BufferedReader<C>`]consume().(5);
216 {
217 let result = bio3.datarust-analyzer cargo buffered-reader 1.4.1 impl#[`Box<dyn BufferedReader<C> + 'a>`][`BufferedReader<C>`]data().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
218 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0);
219 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result, &b""[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().);
220 }
221
222 bio3.into_innerrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#into_inner().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().into_innerrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#into_inner().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
223 };
224
225 {
226 {
227 let result = bio.datarust-analyzer cargo buffered-reader 1.4.1 impl#[`Box<dyn BufferedReader<C> + 'a>`][`BufferedReader<C>`]data().(15).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
228 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 15);
229 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result, &b"567890123456789"[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().);
230 }
231 bio.consumerust-analyzer cargo buffered-reader 1.4.1 impl#[`Box<dyn BufferedReader<C> + 'a>`][`BufferedReader<C>`]consume().(15);
232 {
233 let result = bio.datarust-analyzer cargo buffered-reader 1.4.1 impl#[`Box<dyn BufferedReader<C> + 'a>`][`BufferedReader<C>`]data().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
234 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0);
235 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result, &b""[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().);
236 }
237 }
238 }
239 }
240
241 // Test that buffer() returns the same data as data().
242 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
243 fn buffer_testrust-analyzer cargo buffered-reader 1.4.1 limitor/test/buffer_test().() {
244 // Test vector.
245 let size = 10 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().default_buf_sizerust-analyzer cargo buffered-reader 1.4.1 default_buf_size().();
246 let mut input = 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().(size);
247 let mut v = 0u8;
248 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#size {
249 input.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(v);
250 if v rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::u8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core legacy_int_modules/u8/::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core legacy_int_modules/u8/MAX. {
251 v = 0;
252 } else {
253 v rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign().1;
254 }
255 }
256
257 let reader = Genericrust-analyzer cargo buffered-reader 1.4.1 generic/Generic#::newrust-analyzer cargo buffered-reader 1.4.1 generic/impl#[`Generic<T, ()>`]new().(&input[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
258 let size = size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().2;
259 let input = &input[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#size]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().;
260 let mut reader = Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#::newrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, ()>`]new().(reader, input.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as u64);
261
262 // Gather some stats to make it easier to figure out whether
263 // this test is working.
264 let stats_count = 2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().default_buf_sizerust-analyzer cargo buffered-reader 1.4.1 default_buf_size().();
265 let mut stats = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0usize; stats_count];
266
267 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#input.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
268 let data = reader.datarust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]data().(default_buf_sizerust-analyzer cargo buffered-reader 1.4.1 default_buf_size().() 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().1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().();
269 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().data.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
270 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(data, reader.bufferrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]buffer().());
271 // And, we may as well check to make sure we read the
272 // right data.
273 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(data, &input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i..i+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().data.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
274
275 stats[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().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().(data.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), stats_count 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().1)]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
276
277 // Consume one byte and see what happens.
278 reader.consumerust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]consume().(1);
279 }
280
281 if false {
282 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#stats.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() {
283 if stats[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 {
284 if i 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().stats.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() 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().1 {
285 eprintrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/eprint!!(">=");
286 }
287 eprintlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/eprintln!!("{}: {}", i, stats[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().);
288 }
289 }
290 }
291 }
292
293 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
294 fn consummatedrust-analyzer cargo buffered-reader 1.4.1 limitor/test/consummated().() {
295 let data = b"0123456789";
296
297 let mut l = Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#::newrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, ()>`]new().(Memoryrust-analyzer cargo buffered-reader 1.4.1 memory/Memory#::newrust-analyzer cargo buffered-reader 1.4.1 memory/impl#[`Memory<'a, ()>`]new().(data), 10);
298 l.drop_eofrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#drop_eof().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
299 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(l.consummatedrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]consummated().());
300
301 let mut l = Limitorrust-analyzer cargo buffered-reader 1.4.1 limitor/Limitor#::newrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, ()>`]new().(Memoryrust-analyzer cargo buffered-reader 1.4.1 memory/Memory#::newrust-analyzer cargo buffered-reader 1.4.1 memory/impl#[`Memory<'a, ()>`]new().(data), 20);
302 l.drop_eofrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#drop_eof().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
303 eprintlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/eprintln!!("{:?}", l);
304 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(). l.consummatedrust-analyzer cargo buffered-reader 1.4.1 limitor/impl#[`Limitor<T, C>`][`BufferedReader<C>`]consummated().());
305 }
306 }