1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 13:07:46 +00:00

Closure syntax

This commit is contained in:
Michael Gehring 2015-03-08 19:06:04 +01:00
parent 0d7ac019d1
commit bce3382fd2
6 changed files with 7 additions and 7 deletions

View file

@ -268,7 +268,7 @@ ers of 1000).",
None => 1024
};
let convert_size = |&: size: u64| -> String {
let convert_size = |size: u64| -> String {
if matches.opt_present("human-readable") || matches.opt_present("si") {
if size >= MB {
format!("{:.1}M", (size as f64) / (MB as f64))

View file

@ -124,7 +124,7 @@ fn fold_file<T: io::Reader>(file: BufferedReader<T>, bytes: bool, spaces: bool,
let slice = {
let slice = &line[i..i + width];
if spaces && i + width < len {
match slice.rfind(|&: ch: char| ch.is_whitespace()) {
match slice.rfind(|ch: char| ch.is_whitespace()) {
Some(m) => &slice[..m + 1],
None => slice
}

View file

@ -161,7 +161,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
verbose: matches.opt_present("v"),
};
let string_to_path = |&: s: &String| { Path::new(s.as_slice()) };
let string_to_path = |s: &String| { Path::new(s.as_slice()) };
let paths: Vec<Path> = matches.free.iter().map(string_to_path).collect();
if matches.opt_present("version") {

View file

@ -90,8 +90,8 @@ fn print_usage(opts: &[OptGroup]) {
}
fn parse_size(size: &str) -> Option<u64> {
let ext = size.trim_left_matches(|&: c: char| c.is_digit(10));
let num = size.trim_right_matches(|&: c: char| c.is_alphabetic());
let ext = size.trim_left_matches(|c: char| c.is_digit(10));
let num = size.trim_right_matches(|c: char| c.is_alphabetic());
let mut recovered = num.to_string();
recovered.push_str(ext);
if recovered.as_slice() != size {

View file

@ -336,7 +336,7 @@ fn path(path: &[u8], cond: PathCondition) -> bool {
Write = 0o2,
Execute = 0o1,
}
let perm = |&: stat: stat, p: Permission| {
let perm = |stat: stat, p: Permission| {
use libc::{getgid, getuid};
let (uid, gid) = unsafe { (getuid(), getgid()) };
if uid == stat.st_uid {

View file

@ -96,7 +96,7 @@ fn delete(set: Vec<char>, complement: bool) {
bset.insert(c as usize);
}
let is_allowed = |&: c : char| {
let is_allowed = |c : char| {
if complement {
bset.contains(&(c as usize))
} else {