Try_v2
Provides a derive macro for Try & optionally Try_ConvertResult for interconversion with
std::result::Result and Try_Iterator for iterating over IntoIterator and collecting from
FromIterator analogous to how Result & Option do this.
See (try_trait_v2) for more details
of the underlying trait.
Requires
- nightly
#![feature(never_type)]#![feature(try_trait_v2)]#![feature(try_trait_v2_residual)]- optionally:
#
Limitations on the annotated type
- must be an
enum - must have at least one generic type
- the first generic type must be the
Outputtype (produced when not short circuiting) - the output variant (does not short-circuit) must be the first variant and store the output type as the only unnamed field
See the full documentation for specifics on the generated code.
Example Usage
use ;
// Basic short circuiting thanks to `#[derive(Try)]`
assert!;
// Conversion from std::result::Result thanks to `#[derive(Try_ConvertResult)]`
assert!;
MSRV
1.85.1, in case you are using a fixed version of nightly just to get access to specific unstable features.
Currently untested (may work, may not ...)
whereclauses- storing
Fns in variants