Merge pull request #5649 from tertsdiepraam/remove-collect-lossy-and-ignore

all: remove `collect_{lossy,ignore}` calls where possible
This commit is contained in:
Daniel Hofstetter
2023-12-15 16:30:08 +01:00
committed by GitHub
34 changed files with 4 additions and 64 deletions
+1 -2
View File
@@ -87,8 +87,7 @@ pub fn parse_base_cmd_args(
usage: &str,
) -> UResult<Config> {
let command = base_app(about, usage);
let arg_list = args.collect_lossy();
Config::from(&command.try_get_matches_from(arg_list)?)
Config::from(&command.try_get_matches_from(args)?)
}
pub fn base_app(about: &'static str, usage: &str) -> Command {
-2
View File
@@ -174,8 +174,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
let number_mode = if matches.get_flag(options::NUMBER_NONBLANK) {
-2
View File
@@ -33,8 +33,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args).with_exit_code(125)?;
let default_shell: &'static str = "/bin/sh";
-2
View File
@@ -221,8 +221,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
let algo_name: &str = match matches.get_one::<String>(options::ALGORITHM) {
-2
View File
@@ -145,8 +145,6 @@ fn open_file(name: &str, line_ending: LineEnding) -> io::Result<LineReader> {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args)?;
let line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO_TERMINATED));
let filename1 = matches.get_one::<String>(options::FILE_1).unwrap();
-2
View File
@@ -552,8 +552,6 @@ where
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
// get the file to split
-2
View File
@@ -1267,8 +1267,6 @@ fn is_fifo(filename: &str) -> bool {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
let settings: Settings = Parser::new().parse(
-2
View File
@@ -129,8 +129,6 @@ fn generate_ls_colors(fmt: &OutputFmt, sep: &str) -> String {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
let files = matches
-2
View File
@@ -21,8 +21,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().after_help(AFTER_HELP).try_get_matches_from(args)?;
let line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO));
-2
View File
@@ -590,8 +590,6 @@ pub fn div_ceil(a: u64, b: u64) -> u64 {
#[uucore::main]
#[allow(clippy::cognitive_complexity)]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
let summarize = matches.get_flag(options::SUMMARIZE);
-1
View File
@@ -118,7 +118,6 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result<ControlFlow<
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().get_matches_from(args);
let no_newline = matches.get_flag(options::NO_NEWLINE);
-2
View File
@@ -98,8 +98,6 @@ pub fn uu_app() -> Command {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
// For expr utility we do not want getopts.
// The following usage should work without escaping hyphens: `expr -15 = 1 + 2 \* \( 3 - -4 \)`
let matches = uu_app().try_get_matches_from(args)?;
-2
View File
@@ -30,8 +30,6 @@ const USAGE: &str = help_usage!("logname.md");
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let _ = uu_app().try_get_matches_from(args)?;
match get_userlogin() {
-2
View File
@@ -22,8 +22,6 @@ mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
let matches = uu_app().try_get_matches_from(args)?;
if matches.contains_id(options::CONTEXT) {
-1
View File
@@ -68,7 +68,6 @@ fn _mknod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_ignore();
// Linux-specific options, not implemented
// opts.optflag("Z", "", "set the SELinux security context to default type");
// opts.optopt("", "context", "like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX");
+3 -3
View File
@@ -12,6 +12,7 @@ use uucore::{format_usage, help_about, help_usage};
use std::env;
use std::error::Error;
use std::ffi::OsStr;
use std::fmt::Display;
use std::io::ErrorKind;
use std::iter;
@@ -308,8 +309,7 @@ impl Params {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let args: Vec<_> = args.collect();
let matches = match uu_app().try_get_matches_from(&args) {
Ok(m) => m,
Err(e) => {
@@ -333,7 +333,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// If POSIXLY_CORRECT was set, template MUST be the last argument.
if matches.contains_id(ARG_TEMPLATE) {
// Template argument was provided, check if was the last one.
if args.last().unwrap() != &options.template {
if args.last().unwrap() != OsStr::new(&options.template) {
return Err(Box::new(MkTempError::TooManyTemplates));
}
}
-1
View File
@@ -87,7 +87,6 @@ impl Options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = match uu_app().try_get_matches_from(args) {
Ok(m) => m,
Err(e) => return Err(e.into()),
-2
View File
@@ -178,8 +178,6 @@ pub mod options {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args)?;
let mut settings = Settings::default();
-2
View File
@@ -74,8 +74,6 @@ impl Display for NohupError {
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args).with_exit_code(125)?;
replace_fds()?;
-2
View File
@@ -36,8 +36,6 @@ const POSIX_NAME_MAX: usize = 14;
#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let args = args.collect_lossy();
let matches = uu_app().try_get_matches_from(args)?;
// set working mode

Some files were not shown because too many files have changed in this diff Show More