fix: derive `Default` when possible
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Ref https://rust-lang.github.io/rust-clippy/master/index.html#/derivable_impls
authored by xtqqczze · committed by GitHub · parent 57c190d · Browse files · 1 file·+14 added−49 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+14 added−49 removed
- other:+14 added−49 removed
Provenance
- Commit
cd1f981- Tree
7cf734c- Author
xtqqczze <45661989+xtqqczze@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
57c190d
1 file changed+14 added−49 removed
modified:crates/core/flags/lowargs.rs+14 added-49 removed
227 unmodified lines228 CompletePowerShell,229 }230 231 /// Indicates how ripgrep should treat binary data.232-#[derive(Debug, Eq, PartialEq)]232+#[derive(Debug, Default, Eq, PartialEq)]233 pub(crate) enum BinaryMode {234 /// Automatically determine the binary mode to use. Essentially, when235 /// a file is searched explicitly, then it will be searched using the236 /// `SearchAndSuppress` strategy. Otherwise, it will be searched in a way237 /// that attempts to skip binary files as much as possible. That is, once238 /// a file is classified as binary, searching will immediately stop.239+ #[default]240 Auto,241 /// Search files even when they have binary data, but if a match is found,242 /// suppress it and emit a warning.243 ///7 unmodified lines251 /// replacement of `NUL` bytes with line terminators.252 AsText,253 }254 254-impl Default for BinaryMode {255- fn default() -> BinaryMode {256- BinaryMode::Auto257- }258-}259-255 /// Indicates what kind of boundary mode to use (line or word).256 #[derive(Debug, Eq, PartialEq)]257 pub(crate) enum BoundaryMode {258 /// Only allow matches when surrounded by line bounaries.4 unmodified lines263 264 /// Indicates the buffer mode that ripgrep should use when printing output.265 ///266 /// The default is `Auto`.272-#[derive(Debug, Eq, PartialEq)]267+#[derive(Debug, Default, Eq, PartialEq)]268 pub(crate) enum BufferMode {269 /// Select the buffer mode, 'line' or 'block', automatically based on270 /// whether stdout is connected to a tty.271+ #[default]272 Auto,273 /// Flush the output buffer whenever a line terminator is seen.274 ///275 /// This is useful when wants to see search results more immediately,6 unmodified lines282 /// lots of results.283 Block,284 }285 290-impl Default for BufferMode {291- fn default() -> BufferMode {292- BufferMode::Auto293- }294-}295-286 /// Indicates the case mode for how to interpret all patterns given to ripgrep.287 ///288 /// The default is `Sensitive`.299-#[derive(Debug, Eq, PartialEq)]289+#[derive(Debug, Default, Eq, PartialEq)]290 pub(crate) enum CaseMode {291 /// Patterns are matched case sensitively. i.e., `a` does not match `A`.292+ #[default]293 Sensitive,294 /// Patterns are matched case insensitively. i.e., `a` does match `A`.295 Insensitive,296 /// Patterns are automatically matched case insensitively only when they1 unmodified line298 /// `a` will match `A` but `A` will not match `a`.299 Smart,300 }301 311-impl Default for CaseMode {312- fn default() -> CaseMode {313- CaseMode::Sensitive314- }315-}316-302 /// Indicates whether ripgrep should include color/hyperlinks in its output.303 ///304 /// The default is `Auto`.320-#[derive(Debug, Eq, PartialEq)]305+#[derive(Debug, Default, Eq, PartialEq)]306 pub(crate) enum ColorChoice {307 /// Color and hyperlinks will never be used.308 Never,309 /// Color and hyperlinks will be used only when stdout is connected to a310 /// tty.311+ #[default]312 Auto,313 /// Color will always be used.314 Always,315 /// Color will always be used and only ANSI escapes will be used.4 unmodified lines320 /// ripgrep to use ANSI coloring.321 Ansi,322 }323 338-impl Default for ColorChoice {339- fn default() -> ColorChoice {340- ColorChoice::Auto341- }342-}343-324 impl ColorChoice {325 /// Convert this color choice to the corresponding termcolor type.326 pub(crate) fn to_termcolor(&self) -> termcolor::ColorChoice {327 match *self {180 unmodified lines508 509 /// The encoding mode the searcher will use.510 ///511 /// The default is `Auto`.532-#[derive(Debug, Eq, PartialEq)]512+#[derive(Debug, Default, Eq, PartialEq)]513 pub(crate) enum EncodingMode {514 /// Use only BOM sniffing to auto-detect an encoding.515+ #[default]516 Auto,517 /// Use an explicit encoding forcefully, but let BOM sniffing override it.518 Some(grep::searcher::Encoding),519 /// Use no explicit encoding and disable all BOM sniffing. This will1 unmodified line521 /// true encoding.522 Disabled,523 }524 544-impl Default for EncodingMode {545- fn default() -> EncodingMode {546- EncodingMode::Auto547- }548-}549-525 /// The regex engine to use.526 ///527 /// The default is `Default`.553-#[derive(Debug, Eq, PartialEq)]528+#[derive(Debug, Default, Eq, PartialEq)]529 pub(crate) enum EngineChoice {530 /// Uses the default regex engine: Rust's `regex` crate.531 ///532 /// (Well, technically it uses `regex-automata`, but `regex-automata` is533 /// the implementation of the `regex` crate.)534+ #[default]535 Default,536 /// Dynamically select the right engine to use.537 ///538 /// This works by trying to use the default engine, and if the pattern does2 unmodified lines541 /// Uses the PCRE2 regex engine if it's available.542 PCRE2,543 }544 569-impl Default for EngineChoice {570- fn default() -> EngineChoice {571- EngineChoice::Default572- }573-}574-545 /// The field context separator to use to between metadata for each contextual546 /// line.547 ///548 /// The default is `-`.71 unmodified lines620 621 /// Indicates when to use memory maps.622 ///623 /// The default is `Auto`.654-#[derive(Debug, Eq, PartialEq)]624+#[derive(Debug, Default, Eq, PartialEq)]625 pub(crate) enum MmapMode {626 /// This instructs ripgrep to use heuristics for selecting when to and not627 /// to use memory maps for searching.628+ #[default]629 Auto,630 /// This instructs ripgrep to always try memory maps when possible. (Memory631 /// maps are not possible to use in all circumstances, for example, for632 /// virtual files.)3 unmodified lines636 /// contents of a file on to the heap before searching it.637 Never,638 }639 669-impl Default for MmapMode {670- fn default() -> MmapMode {671- MmapMode::Auto672- }673-}674-640 /// Represents a source of patterns that ripgrep should search for.641 ///642 /// The reason to unify these is so that we can retain the order of `-f/--flag`643 /// and `-e/--regexp` flags relative to one another.80 unmodified lines