#error #close #err #type #file-like #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

#1230 in Rust patterns

Download history 82/week @ 2024-03-16 19/week @ 2024-03-23 97/week @ 2024-03-30 71/week @ 2024-04-06 74/week @ 2024-04-13 50/week @ 2024-04-20 28/week @ 2024-04-27 67/week @ 2024-05-04 93/week @ 2024-05-11 35/week @ 2024-05-18 56/week @ 2024-05-25 76/week @ 2024-06-01 212/week @ 2024-06-08 144/week @ 2024-06-15 30/week @ 2024-06-22

425 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

~215KB