Skip to content
Browse files

split this out into a separate module too

  • Loading branch information...
1 parent 3e95a13 commit 0465ddb62b7708819a668aced5ade29cde6a8be0 @doy committed Apr 3, 2013
Showing with 17 additions and 17 deletions.
  1. +1 −1 Makefile
  2. +14 −0 src/guard.rs
  3. +1 −1 src/ios.rs
  4. +1 −0 src/term.rs
  5. +0 −15 src/util.rs
View
2 Makefile
@@ -1,7 +1,7 @@
RUSTC = rustc
MAIN_SOURCE = src/term.rs
-OTHER_SOURCES = src/hexes.rs src/ios.rs src/info.rs src/util.rs src/trie.rs
+OTHER_SOURCES = src/hexes.rs src/ios.rs src/info.rs src/util.rs src/trie.rs src/guard.rs
TESTS = bin/termios bin/termios2 bin/termios3 bin/rl bin/password bin/attrs bin/tput
all: build tests
View
14 src/guard.rs
@@ -0,0 +1,14 @@
+pub fn guard<T> (finally: ~fn (), body: &fn () -> T) -> T {
+ let _guard = Guard { finally: finally };
+ body()
+}
+
+struct Guard {
+ priv finally: ~fn (),
+}
+
+impl Drop for Guard {
+ fn finalize (&self) {
+ (self.finally)();
+ }
+}
View
2 src/ios.rs
@@ -1,5 +1,5 @@
use core::libc::{c_int,c_void};
-use util::guard;
+use guard::guard;
pub fn cooked () -> int {
unsafe { c::cooked() as int }
View
1 src/term.rs
@@ -12,3 +12,4 @@ pub mod info;
pub mod ios;
mod trie;
mod util;
+mod guard;
View
15 src/util.rs
@@ -1,20 +1,5 @@
use core::libc::{c_int,c_uint};
-pub fn guard<T> (finally: ~fn (), body: &fn () -> T) -> T {
- let _guard = Guard { finally: finally };
- body()
-}
-
-struct Guard {
- priv finally: ~fn (),
-}
-
-impl Drop for Guard {
- fn finalize (&self) {
- (self.finally)();
- }
-}
-
// XXX huge hack until there's a better built-in way to do this
pub fn timed_read (timeout: int) -> Option<char> {
let first = unsafe { io_helper::timed_read(timeout as c_int) };

0 comments on commit 0465ddb

Please sign in to comment.
Something went wrong with that request. Please try again.