refactor/polish ~ fix cargo clippy complaints (DRY struct def)

This commit is contained in:
Roy Ivy III 2019-12-26 15:08:10 -06:00
parent ea8ed8d5da
commit fa8540cb15
26 changed files with 90 additions and 90 deletions

View file

@ -339,7 +339,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
};
let convert_size_fn = {
if matches.opt_present("human-readable") || matches.opt_present("si") {
convert_size_human
convert_size_human
} else if matches.opt_present("b") {
convert_size_b
} else if matches.opt_present("k") {

View file

@ -68,9 +68,9 @@ impl ASTNode {
fn new_node(token_idx: usize, op_type: &str, operands: OperandsList) -> Box<ASTNode> {
Box::new(ASTNode::Node {
token_idx: token_idx,
token_idx,
op_type: op_type.into(),
operands: operands,
operands,
})
}
fn new_leaf(token_idx: usize, value: &str) -> Box<ASTNode> {

View file

@ -244,8 +244,8 @@ fn behaviour(matches: &getopts::Matches) -> Result<Behaviour, i32> {
};
Ok(Behaviour {
main_function: main_function,
specified_mode: specified_mode,
main_function,
specified_mode,
suffix: backup_suffix,
verbose: matches.opt_present("v"),
})

View file

@ -260,9 +260,9 @@ impl<'a> State<'a> {
};
State {
key: key,
key,
file_name: name,
file_num: file_num,
file_num,
print_unpaired: print_unpaired == file_num,
lines: f.lines(),
seq: Vec::new(),

View file

@ -697,7 +697,7 @@ fn display_file_name(
Cell {
contents: name,
width: width,
width,
}
}

View file

@ -251,9 +251,9 @@ fn parse_options(args: &Matches) -> Result<NumfmtOptions> {
}?;
Ok(NumfmtOptions {
transform: transform,
padding: padding,
header: header,
transform,
padding,
header,
})
}

View file

@ -43,12 +43,12 @@ impl<'a, I> InputDecoder<'a, I> {
} // fast but uninitialized
InputDecoder {
input: input,
input,
data: bytes,
reserved_peek_length: peek_length,
used_normal_length: 0,
used_peek_length: 0,
byte_order: byte_order,
byte_order,
}
}
}

View file

@ -21,9 +21,9 @@ impl InputOffset {
/// creates a new `InputOffset` using the provided values.
pub fn new(radix: Radix, byte_pos: usize, label: Option<usize>) -> InputOffset {
InputOffset {
radix: radix,
byte_pos: byte_pos,
label: label,
radix,
byte_pos,
label,
}
}

View file

@ -276,15 +276,15 @@ impl OdOptions {
};
Ok(OdOptions {
byte_order: byte_order,
skip_bytes: skip_bytes,
read_bytes: read_bytes,
label: label,
input_strings: input_strings,
formats: formats,
line_bytes: line_bytes,
output_duplicates: output_duplicates,
radix: radix,
byte_order,
skip_bytes,
read_bytes,
label,
input_strings,
formats,
line_bytes,
output_duplicates,
radix,
})
}
}

View file

@ -69,11 +69,11 @@ impl OutputInfo {
OutputInfo {
byte_size_line: line_bytes,
print_width_line: print_width_line,
byte_size_block: byte_size_block,
print_width_block: print_width_block,
spaced_formatters: spaced_formatters,
output_duplicates: output_duplicates,
print_width_line,
byte_size_block,
print_width_block,
spaced_formatters,
output_duplicates,
}
}

View file

@ -15,8 +15,8 @@ impl ParsedFormatterItemInfo {
add_ascii_dump: bool,
) -> ParsedFormatterItemInfo {
ParsedFormatterItemInfo {
formatter_item_info: formatter_item_info,
add_ascii_dump: add_ascii_dump,
formatter_item_info,
add_ascii_dump,
}
}
}

View file

@ -177,7 +177,7 @@ mod tests {
fn new(inputs: Vec<&'a str>, option_names: Vec<&'a str>) -> MockOptions<'a> {
MockOptions {
inputs: inputs.iter().map(|s| s.to_string()).collect::<Vec<_>>(),
option_names: option_names,
option_names,
}
}
}

View file

@ -22,9 +22,9 @@ impl<R> PartialReader<R> {
/// to `None` if there should be no limit.
pub fn new(inner: R, skip: usize, limit: Option<usize>) -> Self {
PartialReader {
inner: inner,
skip: skip,
limit: limit,
inner,
skip,
limit,
}
}
}

View file

@ -41,7 +41,7 @@ impl<R> PeekReader<R> {
/// Create a new `PeekReader` wrapping `inner`
pub fn new(inner: R) -> Self {
PeekReader {
inner: inner,
inner,
temp_buffer: Vec::new(),
}
}

View file

@ -125,13 +125,13 @@ The utmp file will be {}",
}
let pk = Pinky {
include_idle: include_idle,
include_heading: include_heading,
include_fullname: include_fullname,
include_project: include_project,
include_plan: include_plan,
include_home_and_shell: include_home_and_shell,
include_where: include_where,
include_idle,
include_heading,
include_fullname,
include_project,
include_plan,
include_home_and_shell,
include_where,
names: matches.free,
};

View file

@ -96,7 +96,7 @@ pub fn arrnum_int_div_step<'a>(
}
}
DivOut {
quotient: quotient,
quotient,
remainder: rem_out,
}
}

View file

@ -80,11 +80,11 @@ impl Sub {
}
};
Sub {
min_width: min_width,
second_field: second_field,
field_char: field_char,
field_type: field_type,
orig: orig,
min_width,
second_field,
field_char,
field_type,
orig,
}
}
}

View file

@ -248,7 +248,7 @@ fn create_word_set(
word = word.to_lowercase();
}
word_set.insert(WordRef {
word: word,
word,
filename: file.clone(),
global_line_nr: offs + count,
local_line_nr: count,

View file

@ -109,7 +109,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
return 1;
} else {
let options = Options {
force: force,
force,
interactive: {
if matches.opt_present("i") {
InteractiveMode::InteractiveAlways

View file

@ -76,7 +76,7 @@ impl FilenameGenerator {
indices.push(0);
}
FilenameGenerator {
name_len: name_len,
name_len,
nameset_indices: RefCell::new(indices),
exhausted: Cell::new(false),
}
@ -137,12 +137,12 @@ impl<'a> BytesGenerator<'a> {
};
BytesGenerator {
total_bytes: total_bytes,
total_bytes,
bytes_generated: Cell::new(0u64),
block_size: BLOCK_SIZE,
exact: exact,
gen_type: gen_type,
rng: rng,
exact,
gen_type,
rng,
}
}
}

View file

@ -106,14 +106,14 @@ impl<'a> FileMerger<'a> {
fn new(settings: &'a Settings) -> FileMerger<'a> {
FileMerger {
heap: BinaryHeap::new(),
settings: settings,
settings,
}
}
fn push_file(&mut self, mut lines: Lines<BufReader<Box<dyn Read>>>) {
match lines.next() {
Some(Ok(next_line)) => {
let mergeable_file = MergeableFile {
lines: lines,
lines,
current_line: next_line,
settings: &self.settings,
};

View file

@ -396,9 +396,9 @@ impl Stater {
i = j;
tokens.push(Token::Directive {
width: width,
flag: flag,
precision: precision,
width,
flag,
precision,
format: chars[i],
})
}
@ -492,12 +492,12 @@ impl Stater {
Ok(Stater {
follow: matches.opt_present("dereference"),
showfs: showfs,
showfs,
from_user: !fmtstr.is_empty(),
files: matches.free,
default_tokens: default_tokens,
default_dev_tokens: default_dev_tokens,
mount_list: mount_list,
default_tokens,
default_dev_tokens,
mount_list,
})
}

View file

@ -119,8 +119,8 @@ fn open(name: String, append: bool) -> Box<dyn Write> {
}
};
Box::new(NamedWriter {
inner: inner,
path: path,
inner,
path,
}) as Box<dyn Write>
}

View file

@ -45,7 +45,7 @@ impl DeleteOperation {
fn new(set: ExpandSet, complement: bool) -> DeleteOperation {
DeleteOperation {
bset: set.map(|c| c as usize).collect(),
complement: complement,
complement,
}
}
}
@ -70,7 +70,7 @@ impl SqueezeOperation {
fn new(squeeze_set: ExpandSet, complement: bool) -> SqueezeOperation {
SqueezeOperation {
squeeze_set: squeeze_set.map(|c| c as usize).collect(),
complement: complement,
complement,
}
}
}
@ -100,7 +100,7 @@ impl DeleteAndSqueezeOperation {
DeleteAndSqueezeOperation {
delete_set: delete_set.map(|c| c as usize).collect(),
squeeze_set: squeeze_set.map(|c| c as usize).collect(),
complement: complement,
complement,
}
}
}

View file

@ -76,10 +76,10 @@ impl Options {
};
Options {
files: files,
tabstops: tabstops,
aflag: aflag,
uflag: uflag,
files,
tabstops,
aflag,
uflag,
}
}
}

View file

@ -204,21 +204,21 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
let mut who = Who {
do_lookup: do_lookup,
short_list: short_list,
short_output: short_output,
include_idle: include_idle,
include_heading: include_heading,
include_mesg: include_mesg,
include_exit: include_exit,
need_boottime: need_boottime,
need_deadprocs: need_deadprocs,
need_login: need_login,
need_initspawn: need_initspawn,
need_clockchange: need_clockchange,
need_runlevel: need_runlevel,
need_users: need_users,
my_line_only: my_line_only,
do_lookup,
short_list,
short_output,
include_idle,
include_heading,
include_mesg,
include_exit,
need_boottime,
need_deadprocs,
need_login,
need_initspawn,
need_clockchange,
need_runlevel,
need_users,
my_line_only,
has_records: false,
args: matches.free,
};