syscalls icon indicating copy to clipboard operation
syscalls copied to clipboard

Sysno::from_str should return well error type

Open rusty-snake opened this issue 1 year ago • 0 comments

See https://rust-lang.github.io/api-guidelines/interoperability.html#c-good-err

I would recommend a type like the following:

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
struct ParseSysnoError {
    string: String,
}
impl fmt::Display for ParseSysnoError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "provided string '{}' was not a known syscall", &self.string)?;

        Ok(())
    }
}
impl std::error::Error for ParseSysnoError {}

rusty-snake avatar Aug 08 '24 10:08 rusty-snake