macro_rules! warning {
($($arg:tt)+) => { ... };
}
Expand description
Macro to use warning()
with a format
string.
ยงExample
struct FileSize;
impl Builtin for FileSize {
fn call(&mut self, args: &mut Args) -> Result<()> {
let stdout_handle = io::stdout();
let mut output = BufWriter::new(stdout_handle.lock());
let mut result = Ok(());
for path in args.path_arguments() {
match fs::metadata(&path) {
Ok(m) => {
writeln!(&mut output, "{}\t{}", m.len(), path.display())?;
}
Err(e) => {
warning!("{}: {}", path.display(), e);
result = Err(Error::ExitCode(1));
}
}
}
result
}
}