ls: simplify extraction of indices

This commit is contained in:
xtqqczze
2026-04-20 16:52:31 +02:00
committed by Daniel Hofstetter
parent 742e8ca27f
commit c8813c8331
+6 -6
View File
@@ -311,9 +311,9 @@ fn extract_sort(options: &clap::ArgMatches) -> Sort {
};
let sort_index = options
.get_one::<String>(options::SORT)
.and_then(|_| options.indices_of(options::SORT))
.map_or(0, |mut indices| indices.next_back().unwrap_or(0));
.indices_of(options::SORT)
.and_then(|mut it| it.next_back())
.unwrap_or(0);
let time_index = get_last_index(options::sort::TIME);
let size_index = get_last_index(options::sort::SIZE);
let none_index = get_last_index(options::sort::NONE);
@@ -427,9 +427,9 @@ fn extract_color(options: &clap::ArgMatches) -> bool {
};
let color_index = options
.get_one::<String>(options::COLOR)
.and_then(|_| options.indices_of(options::COLOR))
.map_or(0, |mut indices| indices.next_back().unwrap_or(0));
.indices_of(options::COLOR)
.and_then(|mut it| it.next_back())
.unwrap_or(0);
let unsorted_all_index = get_last_index(options::files::UNSORTED_ALL);
let color_enabled = match options.get_one::<String>(options::COLOR) {