refactor/od ~ fix cargo clippy complaint (clippy::needless_borrow)

This commit is contained in:
Roy Ivy III 2021-06-05 23:00:31 -05:00
parent 63112783b2
commit 94f5011662
4 changed files with 11 additions and 11 deletions

View file

@ -115,7 +115,7 @@ impl<'a> MemoryDecoder<'a> {
/// Creates a clone of the internal buffer. The clone only contain the valid data.
pub fn clone_buffer(&self, other: &mut Vec<u8>) {
other.clone_from(&self.data);
other.clone_from(self.data);
other.resize(self.used_normal_length, 0);
}

View file

@ -130,7 +130,7 @@ impl OdOptions {
let mut skip_bytes = match matches.value_of(options::SKIP_BYTES) {
None => 0,
Some(s) => match parse_number_of_bytes(&s) {
Some(s) => match parse_number_of_bytes(s) {
Ok(i) => i,
Err(_) => {
return Err(format!("Invalid argument --skip-bytes={}", s));
@ -176,7 +176,7 @@ impl OdOptions {
let read_bytes = match matches.value_of(options::READ_BYTES) {
None => None,
Some(s) => match parse_number_of_bytes(&s) {
Some(s) => match parse_number_of_bytes(s) {
Ok(i) => Some(i),
Err(_) => {
return Err(format!("Invalid argument --read-bytes={}", s));
@ -537,7 +537,7 @@ where
print_bytes(
&input_offset.format_byte_offset(),
&memory_decoder,
&output_info,
output_info,
);
}

View file

@ -68,7 +68,7 @@ impl OutputInfo {
let print_width_line = print_width_block * (line_bytes / byte_size_block);
let spaced_formatters =
OutputInfo::create_spaced_formatter_info(&formats, byte_size_block, print_width_block);
OutputInfo::create_spaced_formatter_info(formats, byte_size_block, print_width_block);
OutputInfo {
byte_size_line: line_bytes,

View file

@ -55,7 +55,7 @@ pub fn parse_inputs(matches: &dyn CommandLineOpts) -> Result<CommandLineInputs,
// if any of the options -A, -j, -N, -t, -v or -w are present there is no offset
if !matches.opts_present(&["A", "j", "N", "t", "v", "w"]) {
// test if the last input can be parsed as an offset.
let offset = parse_offset_operand(&input_strings[input_strings.len() - 1]);
let offset = parse_offset_operand(input_strings[input_strings.len() - 1]);
if let Ok(n) = offset {
// if there is just 1 input (stdin), an offset must start with '+'
if input_strings.len() == 1 && input_strings[0].starts_with('+') {
@ -88,7 +88,7 @@ pub fn parse_inputs_traditional(input_strings: Vec<&str>) -> Result<CommandLineI
match input_strings.len() {
0 => Ok(CommandLineInputs::FileNames(vec!["-".to_string()])),
1 => {
let offset0 = parse_offset_operand(&input_strings[0]);
let offset0 = parse_offset_operand(input_strings[0]);
Ok(match offset0 {
Ok(n) => CommandLineInputs::FileAndOffset(("-".to_string(), n, None)),
_ => CommandLineInputs::FileNames(
@ -97,8 +97,8 @@ pub fn parse_inputs_traditional(input_strings: Vec<&str>) -> Result<CommandLineI
})
}
2 => {
let offset0 = parse_offset_operand(&input_strings[0]);
let offset1 = parse_offset_operand(&input_strings[1]);
let offset0 = parse_offset_operand(input_strings[0]);
let offset1 = parse_offset_operand(input_strings[1]);
match (offset0, offset1) {
(Ok(n), Ok(m)) => Ok(CommandLineInputs::FileAndOffset((
"-".to_string(),
@ -114,8 +114,8 @@ pub fn parse_inputs_traditional(input_strings: Vec<&str>) -> Result<CommandLineI
}
}
3 => {
let offset = parse_offset_operand(&input_strings[1]);
let label = parse_offset_operand(&input_strings[2]);
let offset = parse_offset_operand(input_strings[1]);
let label = parse_offset_operand(input_strings[2]);
match (offset, label) {
(Ok(n), Ok(m)) => Ok(CommandLineInputs::FileAndOffset((
input_strings[0].to_string(),