Skip to content

Unsafely unwrap Result and Option types without checking in Rust

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

nvzqz/unsafe-unwrap-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unsafe_unwrap

A Rust library that enables unchecked unwrapping on Option and Result types.

Usage

The unsafe_unwrap() method can be used anywhere unwrap() is used. It behaves similar to unwrap() in unoptimized builds and will remove checks in optimized builds.

extern crate unsafe_unwrap;
use unsafe_unwrap::UnsafeUnwrap;

let x = Some(42);
let y = unsafe { x.unsafe_unwrap() };

Benchmark

bench_normal_unwrap_1000 bench_unsafe_unwrap_1000
929 ns/iter (+/- 176) 302 ns/iter (+/- 28)

License

This project is released under either:

at your choosing.

About

Unsafely unwrap Result and Option types without checking in Rust

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages