dangerous_option 0.2.0

This crate provides DangerousOption - a type similar to ! in Swift language. It's basically an Option which panics if dereferenced while containing None. no_std compatible.
Documentation
  • Coverage
  • 100%
    13 out of 13 items documented0 out of 12 items with examples
  • Size
  • Source code size: 9.82 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.23 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Kixunil/dangerous_option
    5 1 3
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Kixunil

Dangerous Option

About

This crate provides DangerousOption - a type similar to ! in Swift language. It's basically an Option which panics if dereferenced while containing None. This is useful in cases one needs to initialize things a little bit later or when accesses are made via functions called from trusted library.

While such thing might look like a step back (there's a reason we don't have NULL pointers in Rust), there is still one advantage over classic approach of NULL-pointer exceptions (including manually unwrapping): the cause of the bug is usually not in the place where dereferencing happened but in the place where assignment happened. Since this type has only three, very unique methods for creating invalid value, those can be easily searched for and tracked.

This crate is no_std.

License

MITNFA