Expand description
Result<T, Error>
This is a reasonable return type to use throughout your application.
narrate::Result
may be used with one or two type parameters. Therefore
you can import it and not worry about which Result
you are using. Using it
with two types is functionally the same as rust’s standard Result
type.
use narrate::Result;
fn demo1() -> Result<T> {...}
// ^ equivalent to std::result::Result<T, narrate::Error>
fn demo2() -> Result<T, OtherError> {...}
// ^ equivalent to std::result::Result<T, OtherError>
*/
Example
use narrate::Result;
fn run() -> Result<()> {
let config = std::fs::read_to_string("cluster.json")?;
let map: ClusterMap = serde_json::from_str(&config)?;
println!("cluster info: {:#?}", map);
Ok(())
}