given a std::time::SystemTime in the past, I'd like to manipulate elapsed() in a method via:
fn render(&self) -> Result<(), String> {
...
let elapsed = self.start.elapsed()?.as_secs();
...
}
however, ? operator wants to convert std::time::SystemTimeError to String, and From for std::time::SystemTimeError doesn't provide such a conversion. Unfortunately, it doesn't seem like you can:
impl From<std::time::SystemTimeError> for std::time::SystemTimeError {
fn from(e: std::time::SystemTimeError) -> Self { ... }
}
I really don't want to have to add match to handle this, nor do I simply want to unwrap() without error checking. I could define a fn that wraps the match and returns a Result<std::time::Duration, String>, but that seems misguided. What am I missing?
Update: After much futzing around with snafu; yes, I really like it. Adding the SystemTimeError was a breeze. However, it took me a while to sort out how to deal with the errors returned from the other crated (where they are Result<(), String>. I finally found that I just needed to add a GenericError to my Error enum and then implement std::convert::From for Error to create the GenericError.
String. - Kitsu