diff --git a/proxmox-router/src/cli/completion.rs b/proxmox-router/src/cli/completion.rs index 0d9d45ca..109ab3c3 100644 --- a/proxmox-router/src/cli/completion.rs +++ b/proxmox-router/src/cli/completion.rs @@ -257,7 +257,7 @@ impl CommandLineInterface { /// ``stdout``. pub fn print_bash_completion(&self) { let comp_point: usize = match std::env::var("COMP_POINT") { - Ok(val) => match usize::from_str_radix(&val, 10) { + Ok(val) => match val.parse::() { Ok(i) => i, Err(_) => return, }, diff --git a/proxmox-router/src/cli/getopts.rs b/proxmox-router/src/cli/getopts.rs index 8608f3a7..3e972fb7 100644 --- a/proxmox-router/src/cli/getopts.rs +++ b/proxmox-router/src/cli/getopts.rs @@ -223,14 +223,14 @@ fn test_boolean_arg() { for (args, expect) in variants { let res = parse_arguments( &args, - &vec![], + &[], &HashMap::new(), ParameterSchema::from(&PARAMETERS), ); assert!(res.is_ok()); if let Ok((options, remaining)) = res { assert!(options["enable"] == expect); - assert!(remaining.len() == 0); + assert!(remaining.is_empty()); } } } @@ -258,6 +258,6 @@ fn test_argument_paramenter() { if let Ok((options, remaining)) = res { assert!(options["enable"] == true); assert!(options["storage"] == "local"); - assert!(remaining.len() == 0); + assert!(remaining.is_empty()); } } diff --git a/proxmox-router/src/cli/text_table.rs b/proxmox-router/src/cli/text_table.rs index c8972233..cf8dbbd6 100644 --- a/proxmox-router/src/cli/text_table.rs +++ b/proxmox-router/src/cli/text_table.rs @@ -278,9 +278,7 @@ impl TableFormatOptions { let key = key.into(); match self.sortkeys { None => { - let mut list = Vec::new(); - list.push((key, sort_desc)); - self.sortkeys = Some(list); + self.sortkeys = Some(vec![(key, sort_desc)]); } Some(ref mut list) => { list.push((key, sort_desc)); @@ -379,9 +377,7 @@ fn format_table( let sortkeys = if let Some(ref sortkeys) = options.sortkeys { sortkeys.clone() } else { - let mut keys = Vec::new(); - keys.push((properties_to_print[0].clone(), false)); // leftmost, ASC - keys + vec![(properties_to_print[0].clone(), false)] // leftmost, ASC }; let mut sortinfo = Vec::new(); @@ -712,9 +708,7 @@ fn format_object( right_align: all_right_aligned, }; - let mut tabledata: Vec = Vec::new(); - tabledata.push(name_column); - tabledata.push(value_column); + let tabledata = vec![name_column, value_column]; render_table(output, &tabledata, &column_names, options) } diff --git a/proxmox-router/src/permission.rs b/proxmox-router/src/permission.rs index f2e9d469..c0075c59 100644 --- a/proxmox-router/src/permission.rs +++ b/proxmox-router/src/permission.rs @@ -216,7 +216,7 @@ mod test { return groups.contains(&Value::from(group)); } - return false; + false } fn lookup_privs(&self, userid: &str, path: &[&str]) -> u64 { @@ -227,7 +227,7 @@ mod test { } } - return 0; + 0 } } diff --git a/proxmox-schema/src/schema.rs b/proxmox-schema/src/schema.rs index 44f19984..7d9db060 100644 --- a/proxmox-schema/src/schema.rs +++ b/proxmox-schema/src/schema.rs @@ -342,7 +342,7 @@ impl StringSchema { } } ApiStringFormat::Enum(variants) => { - if variants.iter().find(|&e| e.value == value).is_none() { + if !variants.iter().any(|e| e.value == value) { bail!("value '{}' is not defined in the enumeration.", value); } } diff --git a/proxmox-shared-memory/src/lib.rs b/proxmox-shared-memory/src/lib.rs index 487490a0..39f7cfef 100644 --- a/proxmox-shared-memory/src/lib.rs +++ b/proxmox-shared-memory/src/lib.rs @@ -65,7 +65,7 @@ fn mmap_file(file: &mut File, initialize: bool) -> Result, Erro Init::initialize(&mut mmap[0]); } - match Init::check_type_magic(&mut mmap[0]) { + match Init::check_type_magic(&mmap[0]) { Ok(()) => (), Err(err) => bail!("detected wrong types in mmaped files: {}", err), } @@ -164,20 +164,20 @@ impl SharedMemory { drop(file); // no longer required match res { - Ok(_rc) => return Ok(mmap), + Ok(_rc) => Ok(mmap), // if someone else was faster, open the existing file: - Err(nix::Error::Sys(Errno::EEXIST)) => { + Err(nix::Error::Sys(Errno::EEXIST)) => { // if opening fails again now, we'll just error... match nix::fcntl::open(path, oflag, Mode::empty()) { Ok(fd) => { let mut file = unsafe { File::from_raw_fd(fd) }; let mmap = mmap_file(&mut file, false)?; - return Ok(mmap); + Ok(mmap) } Err(err) => bail!("open {:?} failed - {}", path, err), - }; + } } - Err(err) => return Err(err.into()), + Err(err) => Err(err.into()), } } diff --git a/proxmox-sortable-macro/src/lib.rs b/proxmox-sortable-macro/src/lib.rs index 7a5ae45e..a38f7310 100644 --- a/proxmox-sortable-macro/src/lib.rs +++ b/proxmox-sortable-macro/src/lib.rs @@ -102,7 +102,7 @@ fn sort_data(data: TokenStream) -> Result { }); if let Some(err) = err { - return Err(err.into()); + return Err(err); } array.elems = Punctuated::from_iter(fields); diff --git a/proxmox-sys/src/linux/mod.rs b/proxmox-sys/src/linux/mod.rs index 749c8ff6..ad0f79b6 100644 --- a/proxmox-sys/src/linux/mod.rs +++ b/proxmox-sys/src/linux/mod.rs @@ -28,7 +28,7 @@ pub fn fill_with_random_data(buffer: &mut [u8]) -> Result<(), Error> { libc::getrandom( buffer.as_mut_ptr() as *mut libc::c_void, buffer.len() as libc::size_t, - 0 as libc::c_uint, + 0_u32, ) }; diff --git a/proxmox-sys/src/logrotate.rs b/proxmox-sys/src/logrotate.rs index 5396c00a..6b82970b 100644 --- a/proxmox-sys/src/logrotate.rs +++ b/proxmox-sys/src/logrotate.rs @@ -36,7 +36,7 @@ impl LogRotate { } Ok(Self { base_path: path.as_ref().to_path_buf(), - options: options.unwrap_or(CreateOptions::new()), + options: options.unwrap_or_default(), compress, max_files, }) @@ -58,7 +58,7 @@ impl LogRotate { } } - fn compress(source_path: &PathBuf, target_path: &PathBuf, options: &CreateOptions) -> Result<(), Error> { + fn compress(source_path: &Path, target_path: &Path, options: &CreateOptions) -> Result<(), Error> { let mut source = File::open(source_path)?; let (fd, tmp_path) = make_tmp_file(target_path, options.clone())?; let target = unsafe { File::from_raw_fd(fd.into_raw_fd()) };