From b55b459e80d7d1ab79c7065b1c4a9f563f7d2d17 Mon Sep 17 00:00:00 2001 From: Arcterus Date: Tue, 25 Mar 2014 18:37:14 -0700 Subject: [PATCH] du: fix for latest Rust --- du/du.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/du/du.rs b/du/du.rs index 21bc836af..7e6f2094c 100644 --- a/du/du.rs +++ b/du/du.rs @@ -39,10 +39,9 @@ struct Options { // this takes `my_stat` to avoid having to stat files multiple times. fn du(path: &Path, mut my_stat: FileStat, - options_arc: Arc, depth: uint) -> ~[Arc] { + options: Arc, depth: uint) -> ~[Arc] { let mut stats = ~[]; let mut futures = ~[]; - let options = options_arc.get(); if my_stat.kind == TypeDirectory { let read = match fs::readdir(path) { @@ -57,7 +56,7 @@ fn du(path: &Path, mut my_stat: FileStat, for f in read.move_iter() { let this_stat = safe_unwrap!(fs::lstat(&f)); if this_stat.kind == TypeDirectory { - let oa_clone = options_arc.clone(); + let oa_clone = options.clone(); futures.push(Future::spawn(proc() { du(&f, this_stat, oa_clone, depth + 1) })) } else { my_stat.size += this_stat.size; @@ -70,14 +69,13 @@ fn du(path: &Path, mut my_stat: FileStat, } for future in futures.mut_iter() { - for stat_arc in future.get().move_rev_iter() { - let stat = stat_arc.get(); + for stat in future.get().move_rev_iter() { if !options.separate_dirs && stat.path.dir_path() == my_stat.path { my_stat.size += stat.size; my_stat.unstable.blocks += stat.unstable.blocks; } if options.max_depth == None || depth < options.max_depth.unwrap() { - stats.push(stat_arc.clone()); + stats.push(stat.clone()); } } } @@ -315,8 +313,7 @@ Try '{program} --help' for more information.", s, program = program); let iter = du(&path, stat, options_arc.clone(), 0).move_iter(); let (_, len) = iter.size_hint(); let len = len.unwrap(); - for (index, stat_arc) in iter.enumerate() { - let stat = stat_arc.get(); + for (index, stat) in iter.enumerate() { let size = match matches.opt_present("apparent-size") { true => stat.unstable.nlink * stat.size, // C's stat is such that each block is assume to be 512 bytes @@ -351,7 +348,7 @@ Try '{program} --help' for more information.", s, program = program); print!("{:<10} {}", convert_size(size), stat.path.display()); } print!("{}", line_separator); - if options_arc.get().total && index == (len - 1) { + if options_arc.total && index == (len - 1) { // The last element will be the total size of the the path under // path_str. We add it to the grand total. grand_total += size; @@ -359,7 +356,7 @@ Try '{program} --help' for more information.", s, program = program); } } - if options_arc.get().total { + if options_arc.total { print!("{:<10} total", convert_size(grand_total)); print!("{}", line_separator); }