[−][src]Crate unchecked_unwrap
unchecked_unwrap
Adds an unchecked version of unwrap()
and expect()
to Option
and Result
for the rust programming language.
Supports no_std
.
Branches
Usage
use unchecked_unwrap::*; let x = Some("air"); assert_eq!(unsafe { x.unchecked_unwrap() }, "air"); let x: Result<u32, &str> = Ok(2); assert_eq!(unsafe { x.unchecked_unwrap() }, 2); let x = Some("value"); assert_eq!(unsafe { x.unchecked_expect("the world is ending") }, "value"); let x: Result<u32, &str> = Ok(2); assert_eq!(unsafe { x.unchecked_expect("the sky is falling down") }, 2);
Crate features
- debug_checks - On by default. Enables the normal checking behavior with panics when
debug-assertions
is enabled. - nightly
- Enables full documentation through
feature(external_doc)
. - Enables benchmarking through
feature(test)
. - Enables implicit caller location through
feature(track_caller)
.
- Enables full documentation through
Documentation
Documentation is available online in the badge links above.
Currently, nightly is needed for full documentation: cargo doc --features nightly
If you are not using nightly, use cargo doc
as usual.
Tests
Is as simple as cargo test
and cargo test --release
.
Benchmarking
Is as simple as cargo bench
.
Currently the nightly version of rust and the feature="nightly"
is needed for benchmarking.
CI
This crate is checked daily by CI to make sure that it builds successfully with the newest versions of rust stable, beta and nightly.
Alternatives
License
This work is dual-licensed under MIT and Apache 2.0. You can choose between one of them if you use this work.
See the LICENSE file for details
SPDX-License-Identifier: MIT OR Apache-2.0
Traits
UncheckedExpect | Trait for |
UncheckedUnwrap | Trait for |