io-result-optional 0.1.3

Provide an optional() method for io::Result.
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented2 out of 3 items with examples
  • Size
  • Source code size: 5.31 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.06 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • kaj/io-result-optional
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kaj

IoResultOptional

A trait for io::Result that adds a method making it easy to tell the difference between a file not found and another error, since a common practice is to handle a file if it exists.

Crate docs Build Status

if let Some(input) = File::open("data").optional()? {
    // The data exists, so handle it ...
    // If it doesn't exist, it is just ignored
    // If there is another error, this function returns it.
}