missing_util_error

Function missing_util_error 

Source
pub fn missing_util_error(
    error_type: UtilErrorType,
    message: impl Into<String>,
) -> impl FnOnce() -> UtilError
Expand description

Helper function for .ok_or_else() to create UtilError on None.

This function creates a closure that generates a UtilError with the specified error type and message when called.

§Examples

// Instead of:
.ok_or_else(|| UtilError::new(UtilErrorType::Other, "Item not found".to_string(), None))

// You can write:
.ok_or_else(missing_util_error(UtilErrorType::Other, "Item not found".to_string()))