diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-12-04 15:20:26 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-12-10 15:13:12 -0800 |
| commit | ec5603bf13ccb95c311fe5ca193a32efe07147a2 (patch) | |
| tree | 6cf2f33e901d673ba63fa781ddb5167beaae42f8 /src/libstd/io | |
| parent | ab3bec91d77150e434ac1480fbb3935213e33dca (diff) | |
| download | rust-ec5603bf13ccb95c311fe5ca193a32efe07147a2.tar.gz rust-ec5603bf13ccb95c311fe5ca193a32efe07147a2.zip | |
librustpkg: Make `io::ignore_io_error()` use RAII; remove a few more
cells.
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/mod.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index edc6728a0c1..d5e216e2426 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -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 |
