librustpkg: Make io::ignore_io_error()
use RAII; remove a few more
cells.
This commit is contained in:
parent
ab3bec91d7
commit
ec5603bf13
7 changed files with 59 additions and 27 deletions
|
@ -241,6 +241,7 @@ Out of scope
|
|||
#[allow(missing_doc)];
|
||||
|
||||
use cast;
|
||||
use condition::Guard;
|
||||
use container::Container;
|
||||
use int;
|
||||
use iter::Iterator;
|
||||
|
@ -394,12 +395,12 @@ condition! {
|
|||
|
||||
/// Helper for wrapper calls where you want to
|
||||
/// ignore any io_errors that might be raised
|
||||
pub fn ignore_io_error<T>(cb: || -> T) -> T {
|
||||
pub fn ignore_io_error() -> Guard<'static,IoError,()> {
|
||||
io_error::cond.trap(|_| {
|
||||
// just swallow the error.. downstream users
|
||||
// who can make a decision based on a None result
|
||||
// won't care
|
||||
}).inside(|| cb())
|
||||
}).guard()
|
||||
}
|
||||
|
||||
/// Helper for catching an I/O error and wrapping it in a Result object. The
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue