1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-04 15:07:47 +00:00

refactor/polish ~ fix cargo clippy complaints ('better' ref indirection)

This commit is contained in:
Roy Ivy III 2019-12-26 11:16:26 -06:00
parent 94c088f452
commit ab87a1ab5f
4 changed files with 15 additions and 15 deletions

View file

@ -158,7 +158,7 @@ impl ASTNode {
} }
} }
pub fn operand_values(&self) -> Result<Vec<String>, String> { pub fn operand_values(&self) -> Result<Vec<String>, String> {
if let &ASTNode::Node { ref operands, .. } = self { if let ASTNode::Node { ref operands, .. } = *self {
let mut out = Vec::with_capacity(operands.len()); let mut out = Vec::with_capacity(operands.len());
for operand in operands { for operand in operands {
match operand.evaluate() { match operand.evaluate() {
@ -341,11 +341,11 @@ fn push_op_to_stack(
out_stack: &mut TokenStack, out_stack: &mut TokenStack,
op_stack: &mut TokenStack, op_stack: &mut TokenStack,
) -> Result<(), String> { ) -> Result<(), String> {
if let &Token::InfixOp { if let Token::InfixOp {
precedence: prec, precedence: prec,
left_assoc: la, left_assoc: la,
.. ..
} = token } = *token
{ {
loop { loop {
match op_stack.last() { match op_stack.last() {

View file

@ -31,16 +31,16 @@ impl Eq for FormatWriter {}
impl fmt::Debug for FormatWriter { impl fmt::Debug for FormatWriter {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self { match *self {
&FormatWriter::IntWriter(ref p) => { FormatWriter::IntWriter(ref p) => {
f.write_str("IntWriter:")?; f.write_str("IntWriter:")?;
fmt::Pointer::fmt(p, f) fmt::Pointer::fmt(p, f)
} }
&FormatWriter::FloatWriter(ref p) => { FormatWriter::FloatWriter(ref p) => {
f.write_str("FloatWriter:")?; f.write_str("FloatWriter:")?;
fmt::Pointer::fmt(p, f) fmt::Pointer::fmt(p, f)
} }
&FormatWriter::MultibyteWriter(ref p) => { FormatWriter::MultibyteWriter(ref p) => {
f.write_str("MultibyteWriter:")?; f.write_str("MultibyteWriter:")?;
fmt::Pointer::fmt(&(*p as *const ()), f) fmt::Pointer::fmt(&(*p as *const ()), f)
} }

View file

@ -542,9 +542,9 @@ impl Stater {
}; };
for t in tokens.into_iter() { for t in tokens.into_iter() {
match t { match *t {
&Token::Char(c) => print!("{}", c), Token::Char(c) => print!("{}", c),
&Token::Directive { Token::Directive {
flag, flag,
width, width,
precision, precision,
@ -751,9 +751,9 @@ impl Stater {
let tokens = &self.default_tokens; let tokens = &self.default_tokens;
for t in tokens.into_iter() { for t in tokens.into_iter() {
match t { match *t {
&Token::Char(c) => print!("{}", c), Token::Char(c) => print!("{}", c),
&Token::Directive { Token::Directive {
flag, flag,
width, width,
precision, precision,

View file

@ -476,7 +476,7 @@ fn bounded_tail(mut file: &File, settings: &Settings) {
let mut stdout = stdout(); let mut stdout = stdout();
for b in &buf[0..bytes_read] { for b in &buf[0..bytes_read] {
print_byte(&mut stdout, b); print_byte(&mut stdout, *b);
} }
if bytes_read == 0 { if bytes_read == 0 {
@ -549,7 +549,7 @@ fn unbounded_tail<T: Read>(reader: &mut BufReader<T>, settings: &Settings) {
} }
let mut stdout = stdout(); let mut stdout = stdout();
for datum in &ringbuf { for datum in &ringbuf {
print_byte(&mut stdout, datum); print_byte(&mut stdout, *datum);
} }
} }
} }