From d38452c9536929b92f57778b5a31913f57a80e88 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 9 Dec 2021 16:24:49 -0600 Subject: [PATCH] refactor: Clarify explicit display order wins Now that we use options, we can rely on that, instead of sentinels, for detecting a default and overriding only a default. Noticed this as part of looking at #1807. --- src/build/app/mod.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/build/app/mod.rs b/src/build/app/mod.rs index 549ce2a511b..b6337cb9d00 100644 --- a/src/build/app/mod.rs +++ b/src/build/app/mod.rs @@ -2879,19 +2879,13 @@ impl<'help> App<'help> { .args .args_mut() .filter(|a| !a.is_positional()) - .filter(|a| a.get_display_order() == 999) .filter(|a| a.provider != ArgProvider::Generated) .enumerate() { - a.disp_ord = Some(i); + a.disp_ord.get_or_insert(i); } - for (i, mut sc) in &mut self - .subcommands - .iter_mut() - .enumerate() - .filter(|&(_, ref sc)| sc.get_display_order() == 999) - { - sc.disp_ord = Some(i); + for (i, sc) in &mut self.subcommands.iter_mut().enumerate() { + sc.disp_ord.get_or_insert(i); } } for sc in &mut self.subcommands {