Skip to content

Commit

Permalink
Manually implement Default to fix compilation with `--no-default-fe…
Browse files Browse the repository at this point in the history
…atures`
  • Loading branch information
alexrutar committed Dec 13, 2024
1 parent d17e29a commit b2e1068
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions matcher/src/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod tests;

use crate::Utf32String;

#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
/// How to treat a case mismatch between two characters.
pub enum CaseMatching {
Expand All @@ -20,24 +20,50 @@ pub enum CaseMatching {
Ignore,
/// Acts like [`Ignore`](CaseMatching::Ignore) if all characters in a pattern atom are
/// lowercase and like [`Respect`](CaseMatching::Respect) otherwise.
#[default]
#[cfg(feature = "unicode-casefold")]
Smart,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
#[allow(clippy::derivable_impls)]
impl Default for CaseMatching {
fn default() -> Self {
#[cfg(feature = "unicode-casefold")]
{
CaseMatching::Smart
}
#[cfg(not(feature = "unicode-casefold"))]
{
CaseMatching::Respect
}
}
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
/// How to handle unicode normalization,
pub enum Normalization {
/// Characters never match their normalized version (`a != ä`).
Never,
/// Acts like [`Never`](Normalization::Never) if any character in a pattern atom
/// would need to be normalized. Otherwise normalization occurs (`a == ä` but `ä != a`).
#[default]
#[cfg(feature = "unicode-normalization")]
Smart,
}

#[allow(clippy::derivable_impls)]
impl Default for Normalization {
fn default() -> Self {
#[cfg(feature = "unicode-normalization")]
{
Normalization::Smart
}
#[cfg(not(feature = "unicode-normalization"))]
{
Normalization::Never
}
}
}

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[non_exhaustive]
/// The kind of matching algorithm to run for an atom.
Expand Down

0 comments on commit b2e1068

Please sign in to comment.