Debian Codegraph @

src/std_tests.rs

raw symbols SCIP
1 // Original implementation Copyright 2013 The Rust Project Developers <https://github.com/rust-lang>
2 // Original source file: https://github.com/rust-lang/rust/blob/master/src/libstd/io/buffered.rs
3 // Modifications copyright 2016-2018 Austin Bonander <[email protected]>
4
5 //! These tests are copied from rust/src/libstd/io/buffered.rs
6 //! They assume exact capacity allocation
7
8 use craterust-analyzer cargo buffer-redux 1.1.0 crate/::{BufReaderrust-analyzer cargo buffer-redux 1.1.0 BufReader#, BufWriterrust-analyzer cargo buffer-redux 1.1.0 BufWriter#, LineWriterrust-analyzer cargo buffer-redux 1.1.0 LineWriter#};
9 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/::preluderust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/prelude/::*;
10 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/::{selfrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/, SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#};
11
12 /// A dummy reader intended at testing short-reads propagation.
13 pub struct ShortReaderrust-analyzer cargo buffer-redux 1.1.0 std_tests/ShortReader# {
14 pub lengthsrust-analyzer cargo buffer-redux 1.1.0 std_tests/ShortReader#lengths.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<usize>,
15 }
16
17 impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for ShortReaderrust-analyzer cargo buffer-redux 1.1.0 std_tests/ShortReader# {
18 fn readrust-analyzer cargo buffer-redux 1.1.0 std_tests/impl#[ShortReader][Read]read().(&mut self, _: &mut [u8]) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> {
19 if self.lengthsrust-analyzer cargo buffer-redux 1.1.0 std_tests/ShortReader#lengths..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
20 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0)
21 } else {
22 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.lengthsrust-analyzer cargo buffer-redux 1.1.0 std_tests/ShortReader#lengths..removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]remove().(0))
23 }
24 }
25 }
26
27 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
28 fn test_buffered_readerrust-analyzer cargo buffer-redux 1.1.0 std_tests/test_buffered_reader().() {
29 let inner: &[u8] = &[5, 6, 7, 0, 1, 2, 3, 4];
30 let mut reader = BufReaderrust-analyzer cargo buffer-redux 1.1.0 BufReader#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R>`]with_capacity().(2, inner);
31
32 let mut buf = [0, 0, 0];
33 let nread = reader.readrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Read]read().(&mut buf);
34 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(nread.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 3);
35 let b: &[_] = &[5, 6, 7];
36 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf, b);
37
38 let mut buf = [0, 0];
39 let nread = reader.readrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Read]read().(&mut buf);
40 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(nread.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 2);
41 let b: &[_] = &[0, 1];
42 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf, b);
43
44 let mut buf = [0];
45 let nread = reader.readrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Read]read().(&mut buf);
46 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(nread.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1);
47 let b: &[_] = &[2];
48 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf, b);
49
50 let mut buf = [0, 0, 0];
51 let nread = reader.readrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Read]read().(&mut buf);
52 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(nread.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1);
53 let b: &[_] = &[3, 0, 0];
54 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf, b);
55
56 let nread = reader.readrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Read]read().(&mut buf);
57 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(nread.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1);
58 let b: &[_] = &[4, 0, 0];
59 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf, b);
60
61 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.readrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Read]read().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0);
62 }
63
64 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
65 fn test_buffered_reader_seekrust-analyzer cargo buffer-redux 1.1.0 std_tests/test_buffered_reader_seek().() {
66 let inner: &[u8] = &[5, 6, 7, 0, 1, 2, 3, 4];
67 let mut reader = BufReaderrust-analyzer cargo buffer-redux 1.1.0 BufReader#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R>`]with_capacity().(2, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(inner));
68
69 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.seekrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Seek]seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(3)).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3));
70 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.fill_bufrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][BufRead]fill_buf().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&[0, 1][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().));
71 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.stream_positionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#stream_position().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3));
72 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.fill_bufrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][BufRead]fill_buf().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&[0, 1][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().));
73 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.seekrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Seek]seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Currentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Current#(1)).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4));
74 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.fill_bufrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][BufRead]fill_buf().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&[1, 2][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().));
75 reader.consumerust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][BufRead]consume().(1);
76 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.seekrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Seek]seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Currentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Current#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().2)).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3));
77 }
78
79 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
80 fn test_buffered_reader_seek_underflowrust-analyzer cargo buffer-redux 1.1.0 std_tests/test_buffered_reader_seek_underflow().() {
81 // gimmick reader that yields its position modulo 256 for each byte
82 struct PositionReaderrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader# {
83 posrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader#pos.: u64,
84 }
85 impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for PositionReaderrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader# {
86 fn readrust-analyzer cargo buffer-redux 1.1.0 std_tests/impl#[PositionReader][Read]read().(&mut self, buf: &mut [u8]) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> {
87 let len = buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
88 for x in buf {
89 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().x = self.posrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader#pos. as u8;
90 self.posrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader#pos. = self.posrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader#pos..wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]wrapping_add().(1);
91 }
92 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(len)
93 }
94 }
95 impl Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek# for PositionReaderrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader# {
96 fn seekrust-analyzer cargo buffer-redux 1.1.0 std_tests/impl#[PositionReader][Seek]seek().(&mut self, pos: SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<u64> {
97 match pos {
98 SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(n) => {
99 self.posrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader#pos. = n;
100 }
101 SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Currentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Current#(n) => {
102 self.posrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader#pos. = self.posrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader#pos..wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]wrapping_add().(n as u64);
103 }
104 SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Endrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#End#(n) => {
105 self.posrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader#pos. = u64::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]MAX..wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]wrapping_add().(n as u64);
106 }
107 }
108 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.posrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader#pos.)
109 }
110 }
111
112 let mut reader = BufReaderrust-analyzer cargo buffer-redux 1.1.0 BufReader#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R>`]with_capacity().(5, PositionReaderrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader# { posrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader#pos.: 0 });
113 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.fill_bufrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][BufRead]fill_buf().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&[0, 1, 2, 3, 4][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().));
114 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.seekrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Seek]seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Endrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#End#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().5)).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(u64::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]MAX. -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub(). 5));
115 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.fill_bufrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][BufRead]fill_buf().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(5));
116 // the following seek will require two underlying seeks
117 let expected = 9223372036854775802;
118 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
119 reader.seekrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Seek]seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Currentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Current#(i64::MINrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]MIN.)).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(),
120 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(expected)
121 );
122 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.fill_bufrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][BufRead]fill_buf().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(5));
123 // seeking to 0 should empty the buffer.
124 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.stream_positionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#stream_position().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(expected));
125 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`]get_ref().().posrust-analyzer cargo buffer-redux 1.1.0 std_tests/PositionReader#pos., expected);
126 }
127
128 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
129 fn test_read_untilrust-analyzer cargo buffer-redux 1.1.0 std_tests/test_read_until().() {
130 let inner: &[u8] = &[0, 1, 2, 1, 0];
131 let mut reader = BufReaderrust-analyzer cargo buffer-redux 1.1.0 BufReader#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R>`]with_capacity().(2, inner);
132 let mut v = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
133 reader.read_untilrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#read_until().(0, &mut v).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
134 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v, [0]);
135 v.truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]truncate().(0);
136 reader.read_untilrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#read_until().(2, &mut v).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
137 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v, [1, 2]);
138 v.truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]truncate().(0);
139 reader.read_untilrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#read_until().(1, &mut v).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
140 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v, [1]);
141 v.truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]truncate().(0);
142 reader.read_untilrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#read_until().(8, &mut v).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
143 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v, [0]);
144 v.truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]truncate().(0);
145 reader.read_untilrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#read_until().(9, &mut v).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
146 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v, []);
147 }
148
149 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
150 fn test_read_linerust-analyzer cargo buffer-redux 1.1.0 std_tests/test_read_line().() {
151 let in_buf: &[u8] = b"a\nb\nc";
152 let mut reader = BufReaderrust-analyzer cargo buffer-redux 1.1.0 BufReader#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R>`]with_capacity().(2, in_buf);
153 let mut s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
154 reader.read_linerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#read_line().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
155 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, "a\n");
156 s.truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]truncate().(0);
157 reader.read_linerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#read_line().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
158 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, "b\n");
159 s.truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]truncate().(0);
160 reader.read_linerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#read_line().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
161 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, "c");
162 s.truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]truncate().(0);
163 reader.read_linerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#read_line().(&mut s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
164 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, "");
165 }
166
167 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
168 fn test_linesrust-analyzer cargo buffer-redux 1.1.0 std_tests/test_lines().() {
169 let in_buf: &[u8] = b"a\nb\nc";
170 let reader = BufReaderrust-analyzer cargo buffer-redux 1.1.0 BufReader#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R>`]with_capacity().(2, in_buf);
171 let mut it = reader.linesrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#lines().();
172 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impl#[`Lines<B>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "a".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
173 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impl#[`Lines<B>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "b".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
174 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(it.nextrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impl#[`Lines<B>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "c".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
175 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(it.nextrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impl#[`Lines<B>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
176 }
177
178 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
179 fn test_short_readsrust-analyzer cargo buffer-redux 1.1.0 std_tests/test_short_reads().() {
180 let inner = ShortReaderrust-analyzer cargo buffer-redux 1.1.0 std_tests/ShortReader# {
181 lengthsrust-analyzer cargo buffer-redux 1.1.0 std_tests/ShortReader#lengths.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 1, 2, 0, 1, 0],
182 };
183 let mut reader = BufReaderrust-analyzer cargo buffer-redux 1.1.0 BufReader#::newrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R>`]new().(inner);
184 let mut buf = [0, 0];
185 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.readrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Read]read().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0);
186 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.readrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Read]read().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1);
187 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.readrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Read]read().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 2);
188 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.readrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Read]read().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0);
189 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.readrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Read]read().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 1);
190 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.readrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Read]read().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0);
191 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.readrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufReader<R, P>`][Read]read().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0);
192 }
193
194 // BufWriter tests
195 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
196 fn test_buffered_writerrust-analyzer cargo buffer-redux 1.1.0 std_tests/test_buffered_writer().() {
197 let inner = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
198 let mut writer = BufWriterrust-analyzer cargo buffer-redux 1.1.0 BufWriter#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W>`]with_capacity().(2, inner);
199
200 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(writer.capacityrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]capacity().(), 2);
201
202 writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[0, 1]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
203 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]get_ref().(), [0, 1]);
204
205 writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[2]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
206 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]get_ref().(), [0, 1]);
207
208 writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[3]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
209 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]get_ref().(), [0, 1]);
210
211 writer.flushrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`][Write]flush().().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!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]get_ref().(), [0, 1, 2, 3]);
213
214 writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[4]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
215 writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[5]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
216 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]get_ref().(), [0, 1, 2, 3]);
217
218 writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[6]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
219 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]get_ref().(), [0, 1, 2, 3, 4, 5]);
220
221 writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[7, 8]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
222 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]get_ref().(), [0, 1, 2, 3, 4, 5, 6, 7, 8]);
223
224 writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[9, 10, 11]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
225 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]get_ref().(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
226
227 writer.flushrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`][Write]flush().().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!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]get_ref().(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
229 }
230
231 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
232 fn test_buffered_writer_inner_flushesrust-analyzer cargo buffer-redux 1.1.0 std_tests/test_buffered_writer_inner_flushes().() {
233 let mut w = BufWriterrust-analyzer cargo buffer-redux 1.1.0 BufWriter#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W>`]with_capacity().(3, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().());
234 w.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[0, 1]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
235 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().w.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]get_ref().(), []);
236 let w = w.into_innerrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]into_inner().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
237 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(w, [0, 1]);
238 }
239
240 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
241 fn test_buffered_writer_seekrust-analyzer cargo buffer-redux 1.1.0 std_tests/test_buffered_writer_seek().() {
242 let mut w = BufWriterrust-analyzer cargo buffer-redux 1.1.0 BufWriter#::with_capacityrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W>`]with_capacity().(3, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().()));
243 w.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[0, 1, 2, 3, 4, 5]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
244 w.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[6, 7]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
245 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(w.stream_positionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#stream_position().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(8));
246 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&w.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]get_ref().().get_refrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]get_ref().()[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()., &[0, 1, 2, 3, 4, 5, 6, 7][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().);
247 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(w.seekrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`][Seek]seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(2)).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2));
248 w.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[8, 9]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
249 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
250 &w.into_innerrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]into_inner().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().into_innerrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]into_inner().()[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().,
251 &[0, 1, 8, 9, 4, 5, 6, 7]
252 );
253 }
254
255 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
256 fn test_line_bufferrust-analyzer cargo buffer-redux 1.1.0 std_tests/test_line_buffer().() {
257 let mut writer = LineWriterrust-analyzer cargo buffer-redux 1.1.0 LineWriter#::newrust-analyzer cargo buffer-redux 1.1.0 impl#[`LineWriter<W>`]new().(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().());
258 writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[0]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
259 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`LineWriter<W>`]get_ref().(), []);
260 writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[1]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
261 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`LineWriter<W>`]get_ref().(), []);
262 writer.flushrust-analyzer cargo buffer-redux 1.1.0 impl#[`LineWriter<W>`][Write]flush().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
263 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`LineWriter<W>`]get_ref().(), [0, 1]);
264 writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[0, b'\n', 1, b'\n', 2]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
265 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`LineWriter<W>`]get_ref().(), [0, 1, 0, b'\n', 1, b'\n']);
266 writer.flushrust-analyzer cargo buffer-redux 1.1.0 impl#[`LineWriter<W>`][Write]flush().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
267 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`LineWriter<W>`]get_ref().(), [0, 1, 0, b'\n', 1, b'\n', 2]);
268 writer.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[3, b'\n']).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
269 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().writer.get_refrust-analyzer cargo buffer-redux 1.1.0 impl#[`LineWriter<W>`]get_ref().(), [0, 1, 0, b'\n', 1, b'\n', 2, 3, b'\n']);
270 }
271
272 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
273 fn test_buf_writer_drops_oncerust-analyzer cargo buffer-redux 1.1.0 std_tests/test_buf_writer_drops_once().() {
274 struct CountDropsrust-analyzer cargo buffer-redux 1.1.0 std_tests/CountDrops#(usize);
275
276 impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write# for CountDropsrust-analyzer cargo buffer-redux 1.1.0 std_tests/CountDrops# {
277 fn writerust-analyzer cargo buffer-redux 1.1.0 std_tests/impl#[CountDrops][Write]write().(&mut self, _buf: &[u8]) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> {
278 unimplementedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unimplemented!!()
279 }
280
281 fn flushrust-analyzer cargo buffer-redux 1.1.0 std_tests/impl#[CountDrops][Write]flush().(&mut self) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
282 unimplementedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unimplemented!!()
283 }
284 }
285
286 impl Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for CountDropsrust-analyzer cargo buffer-redux 1.1.0 std_tests/CountDrops# {
287 fn droprust-analyzer cargo buffer-redux 1.1.0 std_tests/impl#[CountDrops][Drop]drop().(&mut self) {
288 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(self.0rust-analyzer cargo buffer-redux 1.1.0 std_tests/CountDrops#0., 0);
289 self.0rust-analyzer cargo buffer-redux 1.1.0 std_tests/CountDrops#0. 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;
290 }
291 }
292
293 let writer = BufWriterrust-analyzer cargo buffer-redux 1.1.0 BufWriter#::newrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W>`]new().(CountDropsrust-analyzer cargo buffer-redux 1.1.0 std_tests/CountDrops#(0));
294 let (_, _) = writer.into_inner_with_bufferrust-analyzer cargo buffer-redux 1.1.0 impl#[`BufWriter<W, P>`]into_inner_with_buffer().();
295 }