archive
/
md-pdf-rs
Archived
1
Fork 0

inline result utils

This commit is contained in:
Jake Howard 2017-07-26 15:28:44 +01:00
parent fa601cb023
commit 70c48ea9ab
Signed by: jake
GPG Key ID: 57AFB45680EDD477
1 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,6 @@
use std::fmt::Debug;
#[inline]
pub fn result_override<T, E: Debug>(r: Result<T, E>, msg: String) -> Result<T, String> {
return match r {
Ok(t) => Ok(t),
@ -7,7 +8,8 @@ pub fn result_override<T, E: Debug>(r: Result<T, E>, msg: String) -> Result<T, S
};
}
pub fn result_prefix<T: Debug, E: Debug>(r: Result<T, E>, prefix: String) -> Result<T, String> {
#[inline]
pub fn result_prefix<T, E: Debug>(r: Result<T, E>, prefix: String) -> Result<T, String> {
return match r {
Ok(t) => Ok(t),
Err(e) => Err(format!("{}: {:?}", prefix, e))