Function option_to_result

Source
pub fn option_to_result<T, E, F>(option: Option<T>, err_fn: F) -> Result<T, E>
where F: FnOnce() -> E,
Expand description

Converts an Option to a Result with a custom error message.

ยงExamples

use neo3::prelude::*;
use neo3::neo_utils::error::option_to_result;

let value: Option<u32> = Some(42);
let result = option_to_result(value, || NeoError::Generic { message: "Value is None".to_string() });
assert_eq!(result.unwrap(), 42);