io-result-optional

Crates.ioio-result-optional
lib.rsio-result-optional
version0.1.3
sourcesrc
created_at2019-01-11 21:59:30.635739
updated_at2022-02-02 18:10:40.344252
descriptionProvide an optional() method for io::Result.
homepage
repositoryhttps://github.com/kaj/io-result-optional
max_upload_size
id108016
size5,619
Rasmus Kaj (kaj)

documentation

https://docs.rs/io-result-optional

README

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.
}
Commit count: 5

cargo fmt