Skip to content

Commit e3c663e

Browse files
authored
api: add IntoInnerError::into_error
Currently, for code that doesn't attempt to recover from errors but just reports the error to the caller, it's forced to return the entire `IntoInnerError` even if all one wants is the I/O error. This commit adds `IntoInnerError::into_error` method that consumes `IntoInnerError` and returns contained `io::Error`. This mirrors the API of `std::io::IntoInnerError` in Rust stdlib, which provides such method. PR #304
1 parent f29c9d7 commit e3c663e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/error.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,15 @@ impl<W> IntoInnerError<W> {
312312
&self.err
313313
}
314314

315+
/// Consumes the [`IntoInnerError`] and returns the error which caused the
316+
/// call to [`Writer::into_inner`](crate::Writer::into_inner) to fail.
317+
///
318+
/// Unlike [`IntoInnerError::error`], this can be used to obtain ownership
319+
/// of the underlying error.
320+
pub fn into_error(self) -> io::Error {
321+
self.err
322+
}
323+
315324
/// Returns the underlying writer which generated the error.
316325
///
317326
/// The returned value can be used for error recovery, such as

0 commit comments

Comments
 (0)