aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/util/io.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/util/io.rs')
-rw-r--r--src/components/util/io.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/components/util/io.rs b/src/components/util/io.rs
new file mode 100644
index 00000000000..9fa4dda4a4f
--- /dev/null
+++ b/src/components/util/io.rs
@@ -0,0 +1,14 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+use std::rt::io::{io_error, EndOfFile};
+
+/// Ignore the end-of-file condition within a block of code.
+pub fn ignoring_eof<U>(cb: &fn() -> U) -> U {
+ io_error::cond.trap(|e|
+ match e.kind {
+ EndOfFile => (),
+ _ => io_error::cond.raise(e)
+ }).inside(cb)
+}