I have the following code in Rust that does not compile but shows the intention of what I would like to do.
pub fn parse(cursor: &mut io::Cursor<&[u8]>) -> io::Result<Ack> {
use self::byteorder::{BigEndian, ReadBytesExt};
use self::core::error::Error;
match cursor.read_u16::<BigEndian>() {
Err(byteorder::Error::Io(error)) => Err(error),
Err(error) =>
Err(io::Error::new(io::ErrorKind::Other, error.description(),
None)),
Ok(value) => Ok(Ack { block_number: value })
}
}
Essentially, I want to take a description of the error error returned by byteorder and use it to create a description of the error. I will transfer my library to the user. This is not a mistake packets.rs:166:58: 166:63 error: does not live long enough, and I understand why.
, std::io::Result byteorder::Error::Io. , , , std::io::Error, byteorder::Error. , , , .
Rust . ?
user1096614