Skip to content

Instantly share code, notes, and snippets.

@lilyball
Created May 17, 2014 06:51
Show Gist options
  • Save lilyball/00611608e49d1eba06a2 to your computer and use it in GitHub Desktop.
Save lilyball/00611608e49d1eba06a2 to your computer and use it in GitHub Desktop.
fn process_files(files: Vec<File>, progress: Sender<uint>) {
let mut it = files.iter().filter(|&f| test_file(f)).enumerate();
loop {
let (i, f) = match it.next() {
None => break,
Some(x) => x
};
if i % 100 == 0 {
let (lower, upper) = it.size_hint();
progress.send(upper.unwrap_or(lower));
}
process_file(f);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment