1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
|
error[E0277]: a value of type `Vec<X>` cannot be built from an iterator over elements of type `&X`
--> $DIR/invalid-iterator-chain.rs:6:7
|
LL | let i = i.map(|x| x.clone());
| ------- this method call is cloning the reference `&X`, not `X` which doesn't implement `Clone`
LL | i.collect()
| ^^^^^^^ value of type `Vec<X>` cannot be built from `std::iter::Iterator<Item=&X>`
|
= help: the trait `FromIterator<&_>` is not implemented for `Vec<X>`
but trait `FromIterator<_>` is implemented for it
= help: for that trait implementation, expected `X`, found `&X`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:4:26
|
LL | fn iter_to_vec<'b, X>(i: Iter<'b, X>) -> Vec<X> {
| ^^^^^^^^^^^ `Iterator::Item` is `&X` here
LL | let i = i.map(|x| x.clone());
| ------------------ `Iterator::Item` remains `&X` here
note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
help: consider further restricting type parameter `X`
|
LL | fn iter_to_vec<'b, X>(i: Iter<'b, X>) -> Vec<X> where X: Clone {
| ++++++++++++++
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
--> $DIR/invalid-iterator-chain.rs:15:33
|
LL | println!("{}", scores.sum::<i32>());
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
`i32` implements `Sum<&i32>`
`i32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:12:10
|
LL | let scores = vec![(0, 0)]
| ------------ this expression has type `Vec<({integer}, {integer})>`
LL | .iter()
| ------ `Iterator::Item` is `&({integer}, {integer})` here
LL | .map(|(a, b)| {
| __________^
LL | | a + b;
LL | | });
| |__________^ `Iterator::Item` changed to `()` here
note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
help: consider removing this semicolon
|
LL - a + b;
LL + a + b
|
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
--> $DIR/invalid-iterator-chain.rs:26:20
|
LL | .sum::<i32>(),
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
`i32` implements `Sum<&i32>`
`i32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:25:14
|
LL | vec![0, 1]
| ---------- this expression has type `Vec<{integer}>`
LL | .iter()
| ------ `Iterator::Item` is `&{integer}` here
LL | .map(|x| x * 2)
| -------------- `Iterator::Item` changed to `{integer}` here
LL | .map(|x| x as f64)
| ----------------- `Iterator::Item` changed to `f64` here
LL | .map(|x| x as i64)
| ----------------- `Iterator::Item` changed to `i64` here
LL | .filter(|x| *x > 0)
| ------------------ `Iterator::Item` remains `i64` here
LL | .map(|x| { x + 1 })
| ------------------ `Iterator::Item` remains `i64` here
LL | .map(|x| { x; })
| ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here
note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
help: consider removing this semicolon
|
LL - .map(|x| { x; })
LL + .map(|x| { x })
|
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `f64`
--> $DIR/invalid-iterator-chain.rs:36:20
|
LL | .sum::<i32>(),
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<f64>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
`i32` implements `Sum<&i32>`
`i32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:33:14
|
LL | vec![0, 1]
| ---------- this expression has type `Vec<{integer}>`
LL | .iter()
| ------ `Iterator::Item` is `&{integer}` here
LL | .map(|x| x * 2)
| -------------- `Iterator::Item` changed to `{integer}` here
LL | .map(|x| x as f64)
| ^^^^^^^^^^^^^^^^^ `Iterator::Item` changed to `f64` here
LL | .filter(|x| *x > 0.0)
| -------------------- `Iterator::Item` remains `f64` here
LL | .map(|x| { x + 1.0 })
| -------------------- `Iterator::Item` remains `f64` here
note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
--> $DIR/invalid-iterator-chain.rs:38:60
|
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
`i32` implements `Sum<&i32>`
`i32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:38:38
|
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
| ---------- ------ ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here
| | |
| | `Iterator::Item` is `&{integer}` here
| this expression has type `Vec<{integer}>`
note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
help: consider removing this semicolon
|
LL - println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
LL + println!("{}", vec![0, 1].iter().map(|x| { x }).sum::<i32>());
|
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()`
--> $DIR/invalid-iterator-chain.rs:39:46
|
LL | println!("{}", vec![(), ()].iter().sum::<i32>());
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
| |
| required by a bound introduced by this call
|
= help: the trait `Sum<&()>` is not implemented for `i32`
= help: the following other types implement trait `Sum<A>`:
`i32` implements `Sum<&i32>`
`i32` implements `Sum`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:39:33
|
LL | println!("{}", vec![(), ()].iter().sum::<i32>());
| ------------ ^^^^^^ `Iterator::Item` is `&()` here
| |
| this expression has type `Vec<()>`
note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
error[E0277]: a value of type `Vec<i32>` cannot be built from an iterator over elements of type `()`
--> $DIR/invalid-iterator-chain.rs:48:25
|
LL | let g: Vec<i32> = f.collect();
| ^^^^^^^ value of type `Vec<i32>` cannot be built from `std::iter::Iterator<Item=()>`
|
= help: the trait `FromIterator<()>` is not implemented for `Vec<i32>`
but trait `FromIterator<i32>` is implemented for it
= help: for that trait implementation, expected `i32`, found `()`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:44:15
|
LL | let a = vec![0];
| ------- this expression has type `Vec<{integer}>`
LL | let b = a.into_iter();
| ----------- `Iterator::Item` is `{integer}` here
LL | let c = b.map(|x| x + 1);
| -------------- `Iterator::Item` remains `{integer}` here
LL | let d = c.filter(|x| *x > 10 );
| -------------------- `Iterator::Item` remains `{integer}` here
LL | let e = d.map(|x| {
| _______________^
LL | | x + 1;
LL | | });
| |______^ `Iterator::Item` changed to `()` here
LL | let f = e.filter(|_| false);
| ----------------- `Iterator::Item` remains `()` here
note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
help: consider removing this semicolon
|
LL - x + 1;
LL + x + 1
|
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0277`.
|