Open
Description
Hi,
The following code is a common way to return value:
fn parse_version(header: &[u8]) -> Result<Version, &'static str> {
match header.get(0) {
None => Err("invalid header length"),
Some(&1) => Ok(Version::Version1),
Some(&2) => Ok(Version::Version2),
Some(_) => Err("invalid version"),
}
}
By this way, the error will be returned as a &'static str
and we can return any errors with this way, what's the advantage of thiserror
over &'static str
?
Metadata
Metadata
Assignees
Labels
No labels