You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I made TryUnwrap returns a dedicated error as Err, but in practice, I guess there are cases where this is not desired. Sometimes, you will only be interested in the input value returned. (And it's exactly me)
I think it's a good idea to add an attribute such as #[try_unwrap(simple_return_type)] to make try_unwrap_thing returns Result<(A, B, ...), Self> instead of Result<(A, B, ...), TryUnwrapError<Self>>.
Example
#[derive(TryUnwrap)]#[try_unwrap(ref, simple_return_type)]// or #[try_unwrap(simple_error)]// or #[try_unwrap(return_type = simple)]// or... #[try_unwrap(return_type = detailed)] to enable TryUnwrapError?enumMaybe<T>{Just(T),Nothing}fnmain(){matchMaybe::Just("lorem").try_unwrap_nothing(){Ok(()) => println!("nothing"),Err(val) => println!("{}", val.try_unwrap_just().unwrap()),// => "lorem"}}
The text was updated successfully, but these errors were encountered:
I made
TryUnwrap
returns a dedicated error asErr
, but in practice, I guess there are cases where this is not desired. Sometimes, you will only be interested in the input value returned. (And it's exactly me)I think it's a good idea to add an attribute such as
#[try_unwrap(simple_return_type)]
to maketry_unwrap_thing
returnsResult<(A, B, ...), Self>
instead ofResult<(A, B, ...), TryUnwrapError<Self>>
.Example
The text was updated successfully, but these errors were encountered: