I have
#![feature(unicode, decode_utf8)]
extern crate std_unicode;
fn main() {
let src = b"abc";
for c in std_unicode::char::decode_utf8(src) {
println!("{:?}", c);
}
}
This fails with
Compiling playground v0.0.1 (file:///playground)
error[E0271]: type mismatch resolving `<&[u8; 3] as std::iter::IntoIterator>::Item == u8`
--> src/main.rs:7:14
|
7 | for c in std_unicode::char::decode_utf8(src) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found u8
|
= note: expected type `&u8`
found type `u8`
= note: required by `std_unicode::char::decode_utf8`
error[E0271]: type mismatch resolving `<std::slice::Iter<'_, u8> as std::iter::Iterator>::Item == u8`
--> src/main.rs:7:14
|
7 | for c in std_unicode::char::decode_utf8(src) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected reference, found u8
|
= note: expected type `&u8`
found type `u8`
= note: required by `std_unicode::char::DecodeUtf8`
error[E0271]: type mismatch resolving `<std::slice::Iter<'_, u8> as std::iter::Iterator>::Item == u8`
--> src/main.rs:7:5
|
7 | / for c in std_unicode::char::decode_utf8(src) {
8 | | println!("{:?}", c);
9 | | }
| |_____^ expected reference, found u8
|
= note: expected type `&u8`
found type `u8`
= note: required because of the requirements on the impl of `std::iter::Iterator` for `std_unicode::char::DecodeUtf8<std::slice::Iter<'_, u8>>`
Why and what can I do about it? (Changing the argument from src
to src.iter()
or src.into_iter()
doesn't help.)