pub trait OptionExt<T> {
// Required method
fn or_not_found(self, resource_type: &str, resource_id: &str) -> Result<T>;
}Expand description
Extension trait for Option to provide convenient error handling
§Example
use wami_core::error::{Result, OptionExt};
fn example() -> Result<String> {
let user: Option<String> = Some("alice".to_string());
let result = user.or_not_found("User", "alice")?;
Ok(result)
}Required Methods§
Sourcefn or_not_found(self, resource_type: &str, resource_id: &str) -> Result<T>
fn or_not_found(self, resource_type: &str, resource_id: &str) -> Result<T>
Convert None to a ResourceNotFound error
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".