diff --git a/src/printf/cli.rs b/src/printf/cli.rs index 83f3f598c..a6d185017 100644 --- a/src/printf/cli.rs +++ b/src/printf/cli.rs @@ -17,7 +17,7 @@ pub fn err_msg(msg: &str) { // by default stdout only flushes // to console when a newline is passed. #[allow(unused_must_use)] -pub fn flush_char(c: &char) { +pub fn flush_char(c: char) { print!("{}", c); stdout().flush(); } diff --git a/src/printf/tokenize/unescaped_text.rs b/src/printf/tokenize/unescaped_text.rs index ffb84ed50..c036af5b6 100644 --- a/src/printf/tokenize/unescaped_text.rs +++ b/src/printf/tokenize/unescaped_text.rs @@ -190,7 +190,7 @@ impl UnescapedText { // lazy branch eval // remember this fn could be called // many times in a single exec through %b - cli::flush_char(&ch); + cli::flush_char(ch); tmp_str.push(ch); } '\\' => { @@ -210,7 +210,7 @@ impl UnescapedText { x if x == '%' && !subs_mode => { if let Some(follow) = it.next() { if follow == '%' { - cli::flush_char(&ch); + cli::flush_char(ch); tmp_str.push(ch); } else { it.put_back(follow); @@ -223,7 +223,7 @@ impl UnescapedText { } } _ => { - cli::flush_char(&ch); + cli::flush_char(ch); tmp_str.push(ch); } } diff --git a/src/tail/tail.rs b/src/tail/tail.rs index 1a7714901..c88caee7e 100755 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -560,8 +560,8 @@ fn is_seekable(file: &mut T) -> bool { } #[inline] -fn print_byte(stdout: &mut T, ch: &u8) { - if let Err(err) = stdout.write(&[*ch]) { +fn print_byte(stdout: &mut T, ch: u8) { + if let Err(err) = stdout.write(&[ch]) { crash!(1, "{}", err); } } diff --git a/src/tr/tr.rs b/src/tr/tr.rs index b2f81db99..42566141a 100644 --- a/src/tr/tr.rs +++ b/src/tr/tr.rs @@ -33,7 +33,7 @@ static VERSION: &str = env!("CARGO_PKG_VERSION"); const BUFFER_LEN: usize = 1024; trait SymbolTranslator { - fn translate(&self, c: &char, prev_c: &char) -> Option; + fn translate(&self, c: char, prev_c: char) -> Option; } struct DeleteOperation { @@ -51,10 +51,10 @@ impl DeleteOperation { } impl SymbolTranslator for DeleteOperation { - fn translate(&self, c: &char, _prev_c: &char) -> Option { - let uc = *c as usize; + fn translate(&self, c: char, _prev_c: char) -> Option { + let uc = c as usize; if self.complement == self.bset.contains(uc) { - Some(*c) + Some(c) } else { None } @@ -76,11 +76,11 @@ impl SqueezeOperation { } impl SymbolTranslator for SqueezeOperation { - fn translate(&self, c: &char, prev_c: &char) -> Option { - if *prev_c == *c && self.complement != self.squeeze_set.contains(*c as usize) { + fn translate(&self, c: char, prev_c: char) -> Option { + if prev_c == c && self.complement != self.squeeze_set.contains(c as usize) { None } else { - Some(*c) + Some(c) } } } @@ -106,13 +106,13 @@ impl DeleteAndSqueezeOperation { } impl SymbolTranslator for DeleteAndSqueezeOperation { - fn translate(&self, c: &char, prev_c: &char) -> Option { - if self.complement != self.delete_set.contains(*c as usize) - || *prev_c == *c && self.squeeze_set.contains(*c as usize) + fn translate(&self, c: char, prev_c: char) -> Option { + if self.complement != self.delete_set.contains(c as usize) + || prev_c == c && self.squeeze_set.contains(c as usize) { None } else { - Some(*c) + Some(c) } } } @@ -140,8 +140,8 @@ impl TranslateOperation { } impl SymbolTranslator for TranslateOperation { - fn translate(&self, c: &char, _prev_c: &char) -> Option { - Some(*self.translate_map.get(&(*c as usize)).unwrap_or(c)) + fn translate(&self, c: char, _prev_c: char) -> Option { + Some(*self.translate_map.get(&(c as usize)).unwrap_or(&c)) } } @@ -161,7 +161,7 @@ fn translate_input( { // isolation to make borrow checker happy let filtered = buf.chars().filter_map(|c| { - let res = translator.translate(&c, &prev_c); + let res = translator.translate(c, prev_c); if res.is_some() { prev_c = c; }