Type Alias r3bl_rs_utils_core::common::common_result_and_error::CommonResult
source · pub type CommonResult<T> = Result<T, Box<dyn Error + Send + Sync>>;
Expand description
Type alias to make it easy to work with Result
s. Works hand in hand w/ CommonError.
Here’s an example.
ⓘ
pub fn try_from_pair(pair: Pair) -> CommonResult<(Percent, Percent)> {
let first = pair.first.try_into();
let second = pair.second.try_into();
match (first, second) {
(Ok(first), Ok(second)) => Ok((first, second)),
_ => {
let err_msg = format!("Invalid percentage values in tuple: {:?}", pair);
CommonError::new(CommonErrorType::ValueOutOfRange, &err_msg)
}
}
}
Aliased Type§
enum CommonResult<T> {
Ok(T),
Err(Box<dyn Error + Send + Sync>),
}