style: fix treefmt issues in options module

Signed-off-by: Sandro-Alessio Gierens <sandro@gierens.de>
This commit is contained in:
Sandro-Alessio Gierens 2023-09-23 18:38:51 +02:00
parent 8a8f8ee907
commit 201abcccf3
2 changed files with 14 additions and 4 deletions

View file

@ -40,10 +40,14 @@ impl SortField {
/// Returns the default sort field if none is given, or `Err` if the
/// value doesnt correspond to a sort field we know about.
fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
let Some(word) = matches.get(&flags::SORT)? else { return Ok(Self::default()) };
let Some(word) = matches.get(&flags::SORT)? else {
return Ok(Self::default());
};
// Get String because we cant match an OsStr
let Some(word) = word.to_str() else { return Err(OptionsError::BadArgument(&flags::SORT, word.into())) };
let Some(word) = word.to_str() else {
return Err(OptionsError::BadArgument(&flags::SORT, word.into()));
};
let field = match word {
"name" | "filename" => Self::Name(SortCase::AaBbCc),
@ -160,7 +164,9 @@ impl IgnorePatterns {
pub fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
// If there are no inputs, we return a set of patterns that doesnt
// match anything, rather than, say, `None`.
let Some(inputs) = matches.get(&flags::IGNORE_GLOB)? else { return Ok(Self::empty()) };
let Some(inputs) = matches.get(&flags::IGNORE_GLOB)? else {
return Ok(Self::empty());
};
// Awkwardly, though, a glob pattern can be invalid, and we need to
// deal with invalid patterns somehow.

View file

@ -28,7 +28,11 @@ impl UseColours {
None => Self::Automatic,
};
let Some(word) = matches.get_where(|f| f.matches(&flags::COLOR) || f.matches(&flags::COLOUR))? else { return Ok(default_value) };
let Some(word) =
matches.get_where(|f| f.matches(&flags::COLOR) || f.matches(&flags::COLOUR))?
else {
return Ok(default_value);
};
if word == "always" {
Ok(Self::Always)