| Crates.io | io-result-optional |
| lib.rs | io-result-optional |
| version | 0.1.3 |
| created_at | 2019-01-11 21:59:30.635739+00 |
| updated_at | 2022-02-02 18:10:40.344252+00 |
| description | Provide an optional() method for io::Result. |
| homepage | |
| repository | https://github.com/kaj/io-result-optional |
| max_upload_size | |
| id | 108016 |
| size | 5,619 |
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.
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.
}