Macro hsh::to_str_error
source · macro_rules! to_str_error { ($expr:expr) => { ... }; }
Expand description
This macro abstracts away the error handling for the to_string
method. If the method fails, an error is returned with the failure
message.
Example
extern crate hsh;
use hsh::{ to_str_error };
let result: Result<(), String> = Ok(());
let error: Result<(), String> =
Err("Error message".to_string());
let result_str = to_str_error!(result);
assert_eq!(result_str, Ok(()));