[−][src]Crate io_close
Provides an extension trait (Close
) for closing I/O related
types containing a resource which may return an error when closed.
Provided implementations are for standard library types which implement or contain types which implement:
-
IntoRawFd
(Unix) -
IntoRawHandle
orIntoRawSocket
(Windows).
Using Close
enables the handling of I/O errors which might
otherwise be ignored during drop.
BufWriter Example
use std::io::{BufWriter, Result, Write}; use io_close::Close; fn main() -> Result<()> { let data = "hello world".as_bytes(); let mut buffer = BufWriter::new(tempfile::tempfile()?); buffer.write_all(data)?; buffer.close()?; Ok(()) }
Traits
Close | An extension trait for closing I/O related types containing a resource which may return an error when closed. |