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

View file

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