Repository: ogham/exa
File: src/options/view.rs (Rust)

Code before:

        if &word == "default" {
            Ok(Self::DefaultFormat)
        }
        else if &word == "iso" {
            Ok(Self::ISOFormat)
        }
        else if &word == "long-iso" {
            Ok(Self::LongISO)
        }
        else if &word == "full-iso" {
            Ok(Self::FullISO)
        }
        else {
            Err(OptionsError::BadArgument(&flags::TIME_STYLE, word))
        }
    }
}

impl UserFormat {
    fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
        let flag = matches.has(&flags::NUM_UGID)?;
        Ok(if flag { Self::Numeric } else { Self::Name })
    }

}


impl TimeTypes {

    /// Determine which of a file’s time fields should be displayed for it
    /// based on the user’s options.
    ///
    /// There are two separate ways to pick which fields to show: with a
    /// flag (such as `--modified`) or with a parameter (such as
    /// `--time=modified`). An error is signaled if both ways are used.
    ///
    /// It’s valid to show more than one column by passing in more than one
    /// option, but passing *no* options means that the user just wants to
    /// see the default set.
    fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
        let possible_word = matches.get(&flags::TIME)?;
        let modified = matches.has(&flags::MODIFIED)?;
        let changed  = matches.has(&flags::CHANGED)?;
        let accessed = matches.has(&flags::ACCESSED)?;
        let created  = matches.has(&flags::CREATED)?;

        let no_time = matches.has(&flags::NO_TIME)?;

        let time_types = if no_time {
            Self { modified: false, changed: false, accessed: false, created: false }

Review comment (suggestion):
Just a style nitpicking:

```suggestion
}


impl UserFormat {
    fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
        let flag = matches.has(&flags::NUM_UGID)?;
        Ok(if flag { Self::Numeric } else { Self::Name })
    }
}
```

Code after:

        if &word == "default" {
            Ok(Self::DefaultFormat)
        }
        else if &word == "iso" {
            Ok(Self::ISOFormat)
        }
        else if &word == "long-iso" {
            Ok(Self::LongISO)
        }
        else if &word == "full-iso" {
            Ok(Self::FullISO)
        }
        else {
            Err(OptionsError::BadArgument(&flags::TIME_STYLE, word))
        }
    }
}


impl UserFormat {
    fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
        let flag = matches.has(&flags::NUMERIC)?;
        Ok(if flag { Self::Numeric } else { Self::Name })
    }
}


impl TimeTypes {

    /// Determine which of a file’s time fields should be displayed for it
    /// based on the user’s options.
    ///
    /// There are two separate ways to pick which fields to show: with a
    /// flag (such as `--modified`) or with a parameter (such as
    /// `--time=modified`). An error is signaled if both ways are used.
    ///
    /// It’s valid to show more than one column by passing in more than one
    /// option, but passing *no* options means that the user just wants to
    /// see the default set.
    fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
        let possible_word = matches.get(&flags::TIME)?;
        let modified = matches.has(&flags::MODIFIED)?;
        let changed  = matches.has(&flags::CHANGED)?;
        let accessed = matches.has(&flags::ACCESSED)?;
        let created  = matches.has(&flags::CREATED)?;

        let no_time = matches.has(&flags::NO_TIME)?;

        let time_types = if no_time {
            Self { modified: false, changed: false, accessed: false, created: false }