3 stable releases
1.0.2 | Mar 3, 2023 |
---|---|
1.0.1 | Mar 28, 2022 |
#1230 in Rust patterns
425 downloads per month
4KB
close-err - handle errors raised when closing file-like types
Exposes a close
method on files (and similar types), to permit finer grained error handling.
Inspired by close-file
, but more generic and works correctly on unix.
For example:
use std::{io, fs::File};
use close_err::Closable;
fn main() -> Result<(), io::Error> {
let f = File::create("hi.txt")?;
f.close()?;
Ok(())
}
lib.rs
:
Exposes a close
method on files, to permit finer grained error handling.
use close_err::Closable;
use std::{fs::File, io::Write};
let mut f = File::create("abc.txt").unwrap();
f.write_all("hello".as_bytes());
f.close().unwrap();
Dependencies
~215KB