pub trait OptionExt<T> {
// Required methods
fn ok_or_cbkp_error(
self,
code: ErrorCode,
message: impl Into<String>,
) -> Result<T>;
fn ok_or_error(self, error: Error) -> Result<T>;
}Expand description
Extension trait for Option<T> providing panic-safe unwrapping with context
Required Methods§
Sourcefn ok_or_cbkp_error(
self,
code: ErrorCode,
message: impl Into<String>,
) -> Result<T>
fn ok_or_cbkp_error( self, code: ErrorCode, message: impl Into<String>, ) -> Result<T>
Unwrap an option safely, returning a structured error with context if None
§Errors
Returns the specified error code and message if the option is None.
Sourcefn ok_or_error(self, error: Error) -> Result<T>
fn ok_or_error(self, error: Error) -> Result<T>
Unwrap an option safely with a specific error context
§Errors
Returns the provided error if the option is None.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.