Debian Codegraph @

src/tests.rs

raw symbols SCIP
1 // Copyright (c) 2015-2023 Georg Brandl. Licensed under the Apache License,
2 // Version 2.0 <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0>
3 // or the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at
4 // your option. This file may not be copied, modified, or distributed except
5 // according to those terms.
6
7 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/;
8 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#;
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/::{selfrust-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#, ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#};
10
11 use craterust-analyzer cargo iter-read 1.1.0 crate/::{IterReadrust-analyzer cargo iter-read 1.1.0 IterRead#, IterReadItemrust-analyzer cargo iter-read 1.1.0 IterReadItem#};
12
13 #[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:)]
14 struct MyErrorrust-analyzer cargo iter-read 1.1.0 tests/MyError#;
15 type MyResultrust-analyzer cargo iter-read 1.1.0 tests/MyResult#<T> = Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, MyErrorrust-analyzer cargo iter-read 1.1.0 tests/MyError#>;
16
17 impl 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 MyErrorrust-analyzer cargo iter-read 1.1.0 tests/MyError# {
18 fn fmtrust-analyzer cargo iter-read 1.1.0 tests/impl#[MyError][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# {
19 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "oh no")
20 }
21 }
22
23 impl Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for MyErrorrust-analyzer cargo iter-read 1.1.0 tests/MyError# {}
24
25 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<MyErrorrust-analyzer cargo iter-read 1.1.0 tests/MyError#> for 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# {
26 fn fromrust-analyzer cargo iter-read 1.1.0 tests/impl#[`io::Error`][`From<MyError>`]from().(e: MyErrorrust-analyzer cargo iter-read 1.1.0 tests/MyError#) -> 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# {
27 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#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#, e)
28 }
29 }
30
31 fn errrust-analyzer cargo iter-read 1.1.0 tests/err().<T>() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, MyErrorrust-analyzer cargo iter-read 1.1.0 tests/MyError#> {
32 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(MyErrorrust-analyzer cargo iter-read 1.1.0 tests/MyError#)
33 }
34
35 fn check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().<E: IterReadItemrust-analyzer cargo iter-read 1.1.0 IterReadItem#, I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#=E>>(iter: I) {
36 let mut reader = IterReadrust-analyzer cargo iter-read 1.1.0 IterRead#::newrust-analyzer cargo iter-read 1.1.0 impl#[`IterRead<E, I>`]new().(iter);
37 let mut buffer = 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().();
38 reader.read_to_endrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_to_end().(&mut buffer).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
39 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buffer, b"abcdefghijklmnopqrstuvwxyz");
40 }
41
42 fn check_errrust-analyzer cargo iter-read 1.1.0 tests/check_err().<E: IterReadItemrust-analyzer cargo iter-read 1.1.0 IterReadItem#, I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#=E>>(iter: I) {
43 let mut reader = IterReadrust-analyzer cargo iter-read 1.1.0 IterRead#::newrust-analyzer cargo iter-read 1.1.0 impl#[`IterRead<E, I>`]new().(iter);
44 let mut buffer = 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().();
45 let err = reader.read_to_endrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_to_end().(&mut buffer).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
46 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "oh no");
47 }
48
49 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
50 fn test_u8rust-analyzer cargo iter-read 1.1.0 tests/test_u8().() {
51 let test: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = (b'a'..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#b'{').collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
52 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().());
53 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().());
54 }
55
56 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
57 fn test_slicerust-analyzer cargo iter-read 1.1.0 tests/test_slice().() {
58 let test: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(97..100).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
59 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![],
60 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![],
61 (100..101).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
62 (101..120).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
63 (120..123).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()];
64 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().());
65 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|v| v.as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().()));
66 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().());
67 }
68
69 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
70 fn test_arrayrust-analyzer cargo iter-read 1.1.0 tests/test_array().() {
71 let test: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<[u8; 13]> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"abcdefghijklm", *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"nopqrstuvwxyz"];
72 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().());
73 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().());
74
75 let test: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<[u8; 2]> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"ab", *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"cd", *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"ef", *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"gh", *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"ij",
76 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"kl", *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"mn", *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"op", *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"qr", *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"st",
77 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"uv", *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"wx", *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"yz"];
78 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().());
79 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().());
80 }
81
82 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
83 fn test_strrust-analyzer cargo iter-read 1.1.0 tests/test_str().() {
84 let test: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["abcdef".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
85 "g".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
86 "".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
87 "hijklmnopqrstuvwxy".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
88 "z".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()];
89 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().());
90 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|v| v.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()));
91 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().());
92 }
93
94 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
95 fn test_resultrust-analyzer cargo iter-read 1.1.0 tests/test_result().() {
96 let test: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<MyResultrust-analyzer cargo iter-read 1.1.0 tests/MyResult#<u8>> = (b'a'..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#b'{').maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|v| Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
97 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().());
98 let test: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<MyResultrust-analyzer cargo iter-read 1.1.0 tests/MyResult#<u8>> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(b'a'), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(b'b'),
99 errrust-analyzer cargo iter-read 1.1.0 tests/err().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(b'd')];
100 check_errrust-analyzer cargo iter-read 1.1.0 tests/check_err().(test.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().());
101 let test: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<MyResultrust-analyzer cargo iter-read 1.1.0 tests/MyResult#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>>> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
102 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(b"abcdefghijk".to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().()),
103 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(b"lmnopqrstuvwxyz".to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().())];
104 check_equalrust-analyzer cargo iter-read 1.1.0 tests/check_equal().(test.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().());
105 let test: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<MyResultrust-analyzer cargo iter-read 1.1.0 tests/MyResult#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>>> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(b"abc".to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().()),
106 errrust-analyzer cargo iter-read 1.1.0 tests/err().()];
107 check_errrust-analyzer cargo iter-read 1.1.0 tests/check_err().(test.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().());
108 }
109
110
111 #[cfg(feature = "unstable")]
112 mod benchesrust-analyzer cargo iter-read 1.1.0 tests/benches/ {
113 extern crate testrust-analyzer cargo iter-read 1.1.0 tests/benches/test/;
114 use selfrust-analyzer cargo iter-read 1.1.0 tests/benches/::testrust-analyzer cargo test https://github.com/rust-lang/rust/library/test crate/::Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#;
115 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/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#;
116 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/;
117 use craterust-analyzer cargo iter-read 1.1.0 crate/::{IterReadrust-analyzer cargo iter-read 1.1.0 IterRead#, IterReadItemrust-analyzer cargo iter-read 1.1.0 IterReadItem#};
118
119 const Nrust-analyzer cargo iter-read 1.1.0 tests/benches/N.: usize = 200000;
120 const NBrust-analyzer cargo iter-read 1.1.0 tests/benches/NB.: u64 = Nrust-analyzer cargo iter-read 1.1.0 tests/benches/N. as u64;
121 const BYTErust-analyzer cargo iter-read 1.1.0 tests/benches/BYTE.: u8 = 42;
122 // For iter-of-slices benches:
123 // NS: number of slices/vecs, NB: number of bytes per slice/vec
124 const NS_LARGErust-analyzer cargo iter-read 1.1.0 tests/benches/NS_LARGE.: usize = 20;
125 const NB_LARGErust-analyzer cargo iter-read 1.1.0 tests/benches/NB_LARGE.: usize = Nrust-analyzer cargo iter-read 1.1.0 tests/benches/N. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().NS_LARGErust-analyzer cargo iter-read 1.1.0 tests/benches/NS_LARGE.;
126 const NS_SMALLrust-analyzer cargo iter-read 1.1.0 tests/benches/NS_SMALL.: usize = 1000;
127 const NB_SMALLrust-analyzer cargo iter-read 1.1.0 tests/benches/NB_SMALL.: usize = Nrust-analyzer cargo iter-read 1.1.0 tests/benches/N. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().NS_SMALLrust-analyzer cargo iter-read 1.1.0 tests/benches/NS_SMALL.;
128
129 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
130 fn just_iteraterust-analyzer cargo iter-read 1.1.0 tests/benches/just_iterate().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
131 // For comparison.
132 let vec = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![BYTErust-analyzer cargo iter-read 1.1.0 tests/benches/BYTE.; Nrust-analyzer cargo iter-read 1.1.0 tests/benches/N.];
133 b.bytesrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#bytes. = NBrust-analyzer cargo iter-read 1.1.0 tests/benches/NB.;
134 b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| {
135 let _ = vec.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
136 });
137 }
138
139 fn read_allrust-analyzer cargo iter-read 1.1.0 tests/benches/read_all().<E: IterReadItemrust-analyzer cargo iter-read 1.1.0 IterReadItem#, I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#=E>>(iter: I) {
140 let mut reader = IterReadrust-analyzer cargo iter-read 1.1.0 IterRead#::newrust-analyzer cargo iter-read 1.1.0 impl#[`IterRead<E, I>`]new().(iter);
141 let mut buffer = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; Nrust-analyzer cargo iter-read 1.1.0 tests/benches/N.];
142 reader.read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut buffer).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
143 }
144
145 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
146 fn read_u8rust-analyzer cargo iter-read 1.1.0 tests/benches/read_u8().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
147 let vec = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![BYTErust-analyzer cargo iter-read 1.1.0 tests/benches/BYTE.; Nrust-analyzer cargo iter-read 1.1.0 tests/benches/N.];
148 b.bytesrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#bytes. = NBrust-analyzer cargo iter-read 1.1.0 tests/benches/NB.;
149 b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| read_allrust-analyzer cargo iter-read 1.1.0 tests/benches/read_all().(vec.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()));
150 }
151
152 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
153 fn read_ref_u8rust-analyzer cargo iter-read 1.1.0 tests/benches/read_ref_u8().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
154 let vec = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![BYTErust-analyzer cargo iter-read 1.1.0 tests/benches/BYTE.; Nrust-analyzer cargo iter-read 1.1.0 tests/benches/N.];
155 b.bytesrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#bytes. = NBrust-analyzer cargo iter-read 1.1.0 tests/benches/NB.;
156 b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| read_allrust-analyzer cargo iter-read 1.1.0 tests/benches/read_all().(vec.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()));
157 }
158
159 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
160 fn read_small_vec_u8rust-analyzer cargo iter-read 1.1.0 tests/benches/read_small_vec_u8().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
161 let vec = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#NS_SMALLrust-analyzer cargo iter-read 1.1.0 tests/benches/NS_SMALL.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![BYTErust-analyzer cargo iter-read 1.1.0 tests/benches/BYTE.; NB_SMALLrust-analyzer cargo iter-read 1.1.0 tests/benches/NB_SMALL.])
162 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
163 b.bytesrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#bytes. = NBrust-analyzer cargo iter-read 1.1.0 tests/benches/NB.;
164 b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| read_allrust-analyzer cargo iter-read 1.1.0 tests/benches/read_all().(vec.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()));
165 }
166
167 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
168 fn read_large_vec_u8rust-analyzer cargo iter-read 1.1.0 tests/benches/read_large_vec_u8().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
169 let vec = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#NS_LARGErust-analyzer cargo iter-read 1.1.0 tests/benches/NS_LARGE.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![BYTErust-analyzer cargo iter-read 1.1.0 tests/benches/BYTE.; NB_LARGErust-analyzer cargo iter-read 1.1.0 tests/benches/NB_LARGE.])
170 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
171 b.bytesrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#bytes. = NBrust-analyzer cargo iter-read 1.1.0 tests/benches/NB.;
172 b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| read_allrust-analyzer cargo iter-read 1.1.0 tests/benches/read_all().(vec.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()));
173 }
174
175 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
176 fn read_small_slicerust-analyzer cargo iter-read 1.1.0 tests/benches/read_small_slice().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
177 let origin = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![BYTErust-analyzer cargo iter-read 1.1.0 tests/benches/BYTE.; NB_SMALLrust-analyzer cargo iter-read 1.1.0 tests/benches/NB_SMALL.];
178 let vec = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#NS_SMALLrust-analyzer cargo iter-read 1.1.0 tests/benches/NS_SMALL.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| origin.as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
179 b.bytesrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#bytes. = NBrust-analyzer cargo iter-read 1.1.0 tests/benches/NB.;
180 b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| read_allrust-analyzer cargo iter-read 1.1.0 tests/benches/read_all().(vec.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()));
181 }
182
183 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
184 fn read_large_slicerust-analyzer cargo iter-read 1.1.0 tests/benches/read_large_slice().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
185 let origin = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![BYTErust-analyzer cargo iter-read 1.1.0 tests/benches/BYTE.; NB_LARGErust-analyzer cargo iter-read 1.1.0 tests/benches/NB_LARGE.];
186 let vec = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#NS_LARGErust-analyzer cargo iter-read 1.1.0 tests/benches/NS_LARGE.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| origin.as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
187 b.bytesrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#bytes. = NBrust-analyzer cargo iter-read 1.1.0 tests/benches/NB.;
188 b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| read_allrust-analyzer cargo iter-read 1.1.0 tests/benches/read_all().(vec.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()));
189 }
190
191 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
192 fn read_small_stringrust-analyzer cargo iter-read 1.1.0 tests/benches/read_small_string().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
193 let vec = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#NS_SMALLrust-analyzer cargo iter-read 1.1.0 tests/benches/NS_SMALL.)
194 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::repeatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/repeat/repeat().(BYTErust-analyzer cargo iter-read 1.1.0 tests/benches/BYTE. as char).takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(NB_SMALLrust-analyzer cargo iter-read 1.1.0 tests/benches/NB_SMALL.).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>())
195 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
196 b.bytesrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#bytes. = NBrust-analyzer cargo iter-read 1.1.0 tests/benches/NB.;
197 b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| read_allrust-analyzer cargo iter-read 1.1.0 tests/benches/read_all().(vec.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()));
198 }
199
200 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
201 fn read_large_stringrust-analyzer cargo iter-read 1.1.0 tests/benches/read_large_string().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
202 let vec = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#NS_LARGErust-analyzer cargo iter-read 1.1.0 tests/benches/NS_LARGE.)
203 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::repeatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/repeat/repeat().(BYTErust-analyzer cargo iter-read 1.1.0 tests/benches/BYTE. as char).takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(NB_LARGErust-analyzer cargo iter-read 1.1.0 tests/benches/NB_LARGE.).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>())
204 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
205 b.bytesrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#bytes. = NBrust-analyzer cargo iter-read 1.1.0 tests/benches/NB.;
206 b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| read_allrust-analyzer cargo iter-read 1.1.0 tests/benches/read_all().(vec.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()));
207 }
208
209 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
210 fn read_small_strrust-analyzer cargo iter-read 1.1.0 tests/benches/read_small_str().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
211 let origin = iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::repeatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/repeat/repeat().(BYTErust-analyzer cargo iter-read 1.1.0 tests/benches/BYTE. as char).takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(NB_SMALLrust-analyzer cargo iter-read 1.1.0 tests/benches/NB_SMALL.).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>();
212 let vec = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#NS_SMALLrust-analyzer cargo iter-read 1.1.0 tests/benches/NS_SMALL.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| origin.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
213 b.bytesrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#bytes. = NBrust-analyzer cargo iter-read 1.1.0 tests/benches/NB.;
214 b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| read_allrust-analyzer cargo iter-read 1.1.0 tests/benches/read_all().(vec.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()));
215 }
216
217 #[benchrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/bench:]
218 fn read_large_strrust-analyzer cargo iter-read 1.1.0 tests/benches/read_large_str().(b: &mut Bencherrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#) {
219 let origin = iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::repeatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/repeat/repeat().(BYTErust-analyzer cargo iter-read 1.1.0 tests/benches/BYTE. as char).takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(NB_LARGErust-analyzer cargo iter-read 1.1.0 tests/benches/NB_LARGE.).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>();
220 let vec = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#NS_LARGErust-analyzer cargo iter-read 1.1.0 tests/benches/NS_LARGE.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| origin.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
221 b.bytesrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/Bencher#bytes. = NBrust-analyzer cargo iter-read 1.1.0 tests/benches/NB.;
222 b.iterrust-analyzer cargo test https://github.com/rust-lang/rust/library/test bench/impl#[Bencher]iter().(|| read_allrust-analyzer cargo iter-read 1.1.0 tests/benches/read_all().(vec.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().()));
223 }
224 }