try_into_opt!
Overview
Like try!
, but turns a Result
into an Option
, mainly for use in a filter_map
. Provides
early return for errors like try!
does in map
.
try_into_opt!
is different from try_opt!, which
provides early return for functions that return an Option
. try_into_opt
operates on functions
that return a Result
but your code requires an option. This scenario may come up when doing IO
that can fail, but if it succeeds, needs to be filtered in some way.
Usage
Add this to your Cargo.toml
:
[]
= "0.1.0"
And to your crate:
extern crate try_into_opt;
Example
extern crate try_into_opt;
const MAX_NUM: usize = 11usize;
For more details, head over to the documentation.
License
This library is distributed under similar terms to Rust: dual-licensed under the MIT license and the Apache license (version 2.0).
See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.