FromStr::Err should be bounded by str::error::Error
Closed this issue · 2 comments
malbarbo commented
Conceptually FromStr::Err is an error, so the Error bound shouldn't be necessary is the following example
use std::io;
use std::str::FromStr;
use std::borrow::Borrow;
use std::error::Error;
fn from_reader<F, B>(reader: B) -> io::Result<F>
where F: FromStr,
F::Err: 'static + Error + Send + Sync,
B: io::BufRead
{
let line = try!(reader.lines().next().unwrap());
match F::from_str(line.borrow()) {
Ok(r) => Ok(r),
Err(r) => Err(io::Error::new(io::ErrorKind::InvalidData, r))
}
}I think there is other cases like this in std.
alexcrichton commented
As this trait and associated type are stable there may not be a whole lot we can do about this, but if there are unstable traits it seems reasonable to do this.
Mark-Simulacrum commented
I'm going to close this -- we can't really change it now, but labeled with rust 2 breakage wishlist.