Skip to content

Instantly share code, notes, and snippets.

@blt
Last active August 29, 2015 14:07
Show Gist options
  • Save blt/fff9058568b56226b6af to your computer and use it in GitHub Desktop.
Save blt/fff9058568b56226b6af to your computer and use it in GitHub Desktop.
fn main() {
funvsn(&mut std::io::stdio::stdin().chars());
}
// I'd like to make the function type here as generic as possible. All I really
// care about is getting a character iterator but I have two challenges:
//
// * this doesn't compile (rust 0.13.0, nightly)
// * there's a pesky std::io::IoResult in there
fn funvsn<I>(it: I) where I: Iterator<std::io::IoResult<char>> {
for c in it {
println!("{}", c);
}
}
> rustc src/main.rs
src/main.rs:93:5: 93:11 error: the trait `core::iter::Iterator<core::result::Result<char,std::io::IoError>>` is not implemented for the type `&mut std::io::Chars<'_,std::io::buffered::BufferedReader<std::io::stdio::StdReader>>`
src/main.rs:93 funvsn(&mut std::io::stdio::stdin().chars());
^~~~~~
src/main.rs:93:5: 93:11 note: the trait `core::iter::Iterator` must be implemented because it is required by `funvsn`
src/main.rs:93 funvsn(&mut std::io::stdio::stdin().chars());
^~~~~~
error: aborting due to previous error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment