#error #close #err #type #file-like #expose #closable

close-err

Add .close() to file-like types, for error handling

3 stable releases

1.0.2 Mar 3, 2023
1.0.1 Mar 28, 2022

#1237 in Rust patterns

Download history 24/week @ 2024-07-19 80/week @ 2024-07-26 81/week @ 2024-08-02 38/week @ 2024-08-09 14/week @ 2024-08-16 34/week @ 2024-08-23 71/week @ 2024-08-30 30/week @ 2024-09-06 61/week @ 2024-09-13 61/week @ 2024-09-20 32/week @ 2024-09-27 60/week @ 2024-10-04 92/week @ 2024-10-11 41/week @ 2024-10-18 156/week @ 2024-10-25 133/week @ 2024-11-01

445 downloads per month

MIT license

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

~220KB