Skip to main content

enum_ok

Function enum_ok 

Source
pub fn enum_ok<'a, T, E>() -> EnumKp<Result<T, E>, T, &'a Result<T, E>, &'a T, &'a mut Result<T, E>, &'a mut T, for<'b> fn(&'b Result<T, E>) -> Option<&'b T>, for<'b> fn(&'b mut Result<T, E>) -> Option<&'b mut T>, fn(T) -> Result<T, E>>
Expand description

Extract from Result<T, E> - Ok variant

ยงExample

use rust_key_paths::enum_ok;
let result: Result<String, i32> = Ok("success".to_string());
let ok_kp = enum_ok();
assert_eq!(ok_kp.get(&result), Some(&"success".to_string()));