| 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 | |
| 3 | use superrust-analyzer cargo buffered-reader 1.4.1 crate/::*; |
| 4 | |
| 5 | /// A `Reserve` allows a reader to read everything |
| 6 | /// except for the last N bytes (the reserve) from the underlying |
| 7 | /// `BufferedReader`. |
| 8 | /// |
| 9 | /// Note: because the `Reserve` doesn't generally know |
| 10 | /// how much data can be read from the underlying `BufferedReader`, |
| 11 | /// it causes at least N bytes to by buffered. |
| 12 | #[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:)] |
| 13 | pub struct Reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#<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#> { |
| 14 | reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reserve.: usize, |
| 15 | cookierust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#cookie.: C, |
| 16 | readerrust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reader.: T, |
| 17 | } |
| 18 | |
| 19 | assert_send_and_syncrust-analyzer cargo buffered-reader 1.4.1 macros/assert_send_and_sync!!(Reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#<T, C> |
| 20 | where T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C>, |
| 21 | 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#); |
| 22 | |
| 23 | 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 Reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#<T, C> { |
| 24 | fn fmtrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<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# { |
| 25 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Reserve") |
| 26 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("reserve", &self.reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reserve.) |
| 27 | .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | impl<T: BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<()>> Reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#<T, ()> { |
| 32 | /// Instantiates a new `Reserve`. |
| 33 | /// |
| 34 | /// `reader` is the source to wrap. `reserve` is the number of |
| 35 | /// bytes that will not be returned to the reader. |
| 36 | pub fn newrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, ()>`]new().(reader: T, reserve: usize) -> Selfrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, ()>`] { |
| 37 | Selfrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, ()>`]::with_cookierust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`]with_cookie().(reader, reserve, ()) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | 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#> Reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#<T, C> { |
| 42 | /// Like [`Self::new`], but sets a cookie. |
| 43 | /// |
| 44 | /// The cookie can be retrieved using the [`BufferedReader::cookie_ref`] and |
| 45 | /// [`BufferedReader::cookie_mut`] methods, and set using the [`BufferedReader::cookie_set`] method. |
| 46 | pub fn with_cookierust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`]with_cookie().(reader: T, reserve: usize, cookie: C) |
| 47 | -> Reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#<T, C> { |
| 48 | Reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve# { |
| 49 | readerrust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reader., |
| 50 | reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reserve., |
| 51 | cookierust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#cookie., |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | 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 Reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#<T, C> { |
| 57 | fn readrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<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#> { |
| 58 | let to_read = { |
| 59 | let data = self.readerrust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reader..datarust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data().(buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() 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().self.reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reserve.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 60 | if data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() 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().self.reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reserve. { |
| 61 | data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]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().self.reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reserve. |
| 62 | } else { |
| 63 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0); |
| 64 | } |
| 65 | }; |
| 66 | |
| 67 | let to_read = 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().(), to_read); |
| 68 | |
| 69 | self.readerrust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#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()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#to_read]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | 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# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#> BufferedReaderrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#<C> for Reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#<T, C> { |
| 74 | fn bufferrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`][`BufferedReader<C>`]buffer().(&self) -> &[u8] { |
| 75 | let buf = self.readerrust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reader..bufferrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#buffer().(); |
| 76 | if buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() 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().self.reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reserve. { |
| 77 | &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#buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]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().self.reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reserve.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 78 | } else { |
| 79 | b"" |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /// Return the buffer. Ensure that it contains at least `amount` |
| 84 | /// bytes. |
| 85 | fn datarust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<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#> { |
| 86 | let data = self.readerrust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reader..datarust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data().(amount 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().self.reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reserve.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 87 | if data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().self.reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reserve. { |
| 88 | // EOF. |
| 89 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(b"") |
| 90 | } else { |
| 91 | // More than enough. |
| 92 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&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#data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]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().self.reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reserve.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | fn consumerust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`][`BufferedReader<C>`]consume().(&mut self, amount: usize) -> &[u8] { |
| 97 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(amount <= self.bufferrust-analyzer cargo buffered-reader 1.4.1 impl#[`&'a mut T`][`BufferedReader<C>`]buffer().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 98 | |
| 99 | // consume may return more than amount. If it does, make sure |
| 100 | // it doesn't return any of the reserve. |
| 101 | let data = self.readerrust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reader..consumerust-analyzer cargo buffered-reader 1.4.1 BufferedReader#consume().(amount); |
| 102 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() >= amount); |
| 103 | |
| 104 | if data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() 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().amount { |
| 105 | // We got more than `amount`. We need to be careful to |
| 106 | // not return data from the reserve. But, we also know |
| 107 | // that `amount` does not include data from the reserve. |
| 108 | if data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() 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().amount 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().self.reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reserve. { |
| 109 | return &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#data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]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().self.reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reserve.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 110 | } |
| 111 | } |
| 112 | &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#amount]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 113 | } |
| 114 | |
| 115 | fn data_consumerust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<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#> { |
| 116 | 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, self.datarust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`][`BufferedReader<C>`]data().(amount)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 117 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.consumerust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`][`BufferedReader<C>`]consume().(amount)) |
| 118 | } |
| 119 | |
| 120 | fn data_consume_hardrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<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#> { |
| 121 | self.data_hardrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_hard().(amount)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 122 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.consumerust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`][`BufferedReader<C>`]consume().(amount)) |
| 123 | } |
| 124 | |
| 125 | fn get_mutrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<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>> { |
| 126 | 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 reserve/Reserve#reader.) |
| 127 | } |
| 128 | |
| 129 | fn get_refrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<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>> { |
| 130 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&self.readerrust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reader.) |
| 131 | } |
| 132 | |
| 133 | fn into_innerrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<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 reserve/impl#[`Reserve<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>> |
| 134 | where Selfrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`][`BufferedReader<C>`]: 'b { |
| 135 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.readerrust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#reader..into_boxedrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#into_boxed().()) |
| 136 | } |
| 137 | |
| 138 | fn cookie_setrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`][`BufferedReader<C>`]cookie_set().(&mut self, cookie: C) -> C { |
| 139 | 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/; |
| 140 | |
| 141 | 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 reserve/Reserve#cookie., cookie) |
| 142 | } |
| 143 | |
| 144 | fn cookie_refrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`][`BufferedReader<C>`]cookie_ref().(&self) -> &C { |
| 145 | &self.cookierust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#cookie. |
| 146 | } |
| 147 | |
| 148 | fn cookie_mutrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`][`BufferedReader<C>`]cookie_mut().(&mut self) -> &mut C { |
| 149 | &mut self.cookierust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#cookie. |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | #[cfg(test)] |
| 154 | mod testrust-analyzer cargo buffered-reader 1.4.1 reserve/test/ { |
| 155 | use superrust-analyzer cargo buffered-reader 1.4.1 reserve/::*; |
| 156 | |
| 157 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 158 | fn datarust-analyzer cargo buffered-reader 1.4.1 reserve/test/data().() { |
| 159 | use craterust-analyzer cargo buffered-reader 1.4.1 crate/::Memoryrust-analyzer cargo buffered-reader 1.4.1 memory/Memory#; |
| 160 | |
| 161 | // orig is the original buffer |
| 162 | // |
| 163 | // cursor is the Reserve's position in orig. |
| 164 | // |
| 165 | // to_read is how much to read. |
| 166 | // |
| 167 | // total is the total to_read that be read from orig. |
| 168 | // |
| 169 | // cursor / reserve \ |
| 170 | // orig: [ | to_read | | ] |
| 171 | // \ total / |
| 172 | // |
| 173 | fn read_chunkrust-analyzer cargo buffered-reader 1.4.1 reserve/test/read_chunk().<'a, R: 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#>( |
| 174 | orig: &[u8], r: &mut R, to_read: usize, cursor: usize, total: usize, |
| 175 | mode: usize) |
| 176 | { |
| 177 | // Use data. |
| 178 | let data_len = { |
| 179 | let data = r.datarust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data().(to_read).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 180 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(data, &orig[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().cursor..cursor +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 181 | data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() |
| 182 | }; |
| 183 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(data_len <= total -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). cursor); |
| 184 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.bufferrust-analyzer cargo buffered-reader 1.4.1 impl#[`&'a mut T`][`BufferedReader<C>`]buffer().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), data_len); |
| 185 | |
| 186 | // Use data_hard. |
| 187 | let data_hard_len = { |
| 188 | let data_hard = r.data_hardrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_hard().(to_read).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 189 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(data_hard, &orig[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().cursor..cursor +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). data_hard.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 190 | data_hard.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() |
| 191 | }; |
| 192 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(data_len <= data_hard_len); |
| 193 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(data_hard_len <= total -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). cursor); |
| 194 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.bufferrust-analyzer cargo buffered-reader 1.4.1 impl#[`&'a mut T`][`BufferedReader<C>`]buffer().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), data_hard_len); |
| 195 | |
| 196 | |
| 197 | |
| 198 | // Make sure data_hard fails when requesting too much |
| 199 | // data. |
| 200 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.data_hardrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_hard().(total -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). cursor +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 201 | |
| 202 | // And that a failing data_hard does not move the cursor. |
| 203 | let data_len = { |
| 204 | let data = r.datarust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data().(to_read).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 205 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(data, &orig[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().cursor..cursor +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 206 | data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() |
| 207 | }; |
| 208 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(data_len <= total -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). cursor); |
| 209 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.bufferrust-analyzer cargo buffered-reader 1.4.1 impl#[`&'a mut T`][`BufferedReader<C>`]buffer().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), data_len); |
| 210 | |
| 211 | |
| 212 | // Likewise for data_consume_hard. |
| 213 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.data_consume_hardrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_consume_hard().(total -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). cursor +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 214 | |
| 215 | // And that a failing data_hard does not move the cursor. |
| 216 | let data_len = { |
| 217 | let data = r.datarust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data().(to_read).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!!(data, &orig[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().cursor..cursor +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 219 | data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() |
| 220 | }; |
| 221 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(data_len <= total -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). cursor); |
| 222 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.bufferrust-analyzer cargo buffered-reader 1.4.1 impl#[`&'a mut T`][`BufferedReader<C>`]buffer().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), data_len); |
| 223 | |
| 224 | |
| 225 | |
| 226 | // Consume the chunk. |
| 227 | match mode { |
| 228 | 0 => { |
| 229 | // Use consume. |
| 230 | let l = r.consumerust-analyzer cargo buffered-reader 1.4.1 BufferedReader#consume().(to_read).lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(); |
| 231 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(to_read <= l); |
| 232 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(l <= total -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). cursor); |
| 233 | } |
| 234 | 1 => { |
| 235 | // Use data_consume. |
| 236 | let data_len = { |
| 237 | let data = r.data_consumerust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_consume().(to_read).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 238 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(data, &orig[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().cursor..cursor +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 239 | data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() |
| 240 | }; |
| 241 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(data_len <= total -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). cursor); |
| 242 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.bufferrust-analyzer cargo buffered-reader 1.4.1 impl#[`&'a mut T`][`BufferedReader<C>`]buffer().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() <= total -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). cursor -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). to_read); |
| 243 | } |
| 244 | 2 => { |
| 245 | // Use data_consume_hard. |
| 246 | let data_len = { |
| 247 | let data = r.data_consume_hardrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_consume_hard().(to_read).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 248 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(data, &orig[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().cursor..cursor +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 249 | data.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() |
| 250 | }; |
| 251 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(data_len <= total -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). cursor); |
| 252 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.bufferrust-analyzer cargo buffered-reader 1.4.1 impl#[`&'a mut T`][`BufferedReader<C>`]buffer().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() <= total -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). cursor -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). to_read); |
| 253 | } |
| 254 | _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Invalid mode"), |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | fn testrust-analyzer cargo buffered-reader 1.4.1 reserve/test/test().(orig: &[u8], mode: usize, reserve: usize, |
| 259 | mid1: usize, mid2: usize) { |
| 260 | let total = orig.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]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().reserve; |
| 261 | |
| 262 | let mut r = Reserverust-analyzer cargo buffered-reader 1.4.1 reserve/Reserve#::newrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, ()>`]new().( |
| 263 | Memoryrust-analyzer cargo buffered-reader 1.4.1 memory/Memory#::newrust-analyzer cargo buffered-reader 1.4.1 memory/impl#[`Memory<'a, ()>`]new().(orig), reserve); |
| 264 | |
| 265 | // Read the first chunk. |
| 266 | read_chunkrust-analyzer cargo buffered-reader 1.4.1 reserve/test/read_chunk().(orig, &mut r, mid1, 0, total, mode); |
| 267 | |
| 268 | // Read the second chunk. |
| 269 | read_chunkrust-analyzer cargo buffered-reader 1.4.1 reserve/test/read_chunk().(orig, &mut r, mid2 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().mid1, mid1, total, mode); |
| 270 | |
| 271 | // Read the remaining bit. |
| 272 | read_chunkrust-analyzer cargo buffered-reader 1.4.1 reserve/test/read_chunk().(orig, &mut r, total 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().mid2, mid2, total, mode); |
| 273 | |
| 274 | // And, we should be at EOF. |
| 275 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.datarust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`][`BufferedReader<C>`]data().(100).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 276 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.bufferrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`][`BufferedReader<C>`]buffer().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 277 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.data_hardrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_hard().(100).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 278 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.data_hardrust-analyzer cargo buffered-reader 1.4.1 BufferedReader#data_hard().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 0); |
| 279 | |
| 280 | let mut g = 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().(r).into_innerrust-analyzer cargo buffered-reader 1.4.1 reserve/impl#[`Reserve<T, C>`][`BufferedReader<C>`]into_inner().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 281 | read_chunkrust-analyzer cargo buffered-reader 1.4.1 reserve/test/read_chunk().(orig, &mut g, |
| 282 | orig.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]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().total, total, orig.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), |
| 283 | mode); |
| 284 | } |
| 285 | |
| 286 | // 26 letters. |
| 287 | let orig : &[u8] = b"abcdefghijklmnopqrstuvwxyz"; |
| 288 | |
| 289 | // We break up the above into four pieces: three chunks, and |
| 290 | // the reserved area. |
| 291 | for mode in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3 { |
| 292 | for reserve in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#orig.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 293 | let total = orig.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]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().reserve; |
| 294 | |
| 295 | for mid1 in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#total { |
| 296 | for mid2 in mid1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#total { |
| 297 | testrust-analyzer cargo buffered-reader 1.4.1 reserve/test/test().(orig, mode, reserve, mid1, mid2); |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | } |