Skip to content

Instantly share code, notes, and snippets.

@cnd
Last active December 26, 2015 05:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cnd/7098985 to your computer and use it in GitHub Desktop.
Save cnd/7098985 to your computer and use it in GitHub Desktop.
use std::task;
use std::rt::io::timer::sleep;
///<Summary>
///Simple butterfly
///</Summary>
pub fn butterfly<U>(f: &fn() -> U) -> U {
let (port, chan) = stream();
do task::spawn_sched(task::SingleThreaded) {
print(" ");
while !port.peek() {
let bug3911 = ["|","/","-","\\"];
for fly in bug3911.iter() {
print!("\x08{:s}", *fly);
sleep(100);
};
}
}
let ret = f();
chan.send(());
ret
}
do butterfly {
io::stdin().read_line();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment