This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
md-pdf-rs/src/utils.rs

18 lines
413 B
Rust
Raw Normal View History

2017-07-26 15:22:20 +01:00
use std::fmt::Debug;
2017-07-26 15:28:44 +01:00
#[inline]
2017-07-26 15:22:20 +01:00
pub fn result_override<T, E: Debug>(r: Result<T, E>, msg: String) -> Result<T, String> {
return match r {
Ok(t) => Ok(t),
2017-07-26 15:33:13 +01:00
Err(_) => Err(msg),
2017-07-26 15:22:20 +01:00
};
}
2017-07-26 15:28:44 +01:00
#[inline]
pub fn result_prefix<T, E: Debug>(r: Result<T, E>, prefix: String) -> Result<T, String> {
2017-07-26 15:22:20 +01:00
return match r {
Ok(t) => Ok(t),
2017-07-26 15:33:13 +01:00
Err(e) => Err(format!("{}: {:?}", prefix, e)),
2017-07-26 15:22:20 +01:00
};
}