Skip to content

Commit

Permalink
Adds optional feauture "serde" - impl for WildMatch
Browse files Browse the repository at this point in the history
  • Loading branch information
hoijui authored and becheran committed Dec 18, 2023
1 parent 8812f0b commit bbd0cfe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Expand Up @@ -11,13 +11,17 @@ categories = ["algorithms"]
repository = "https://github.com/becheran/wildmatch"

[dependencies]
serde = { version = "1.0", features = ["derive"], optional = true }

[dev-dependencies]
ntest = "0.7.3"
criterion = "0.3.4"
regex = "1.4.3"
glob = "0.3.0"

[features]
serde = ["dep:serde"]

[[bench]]
name = "patterns"
harness = false
5 changes: 5 additions & 0 deletions src/lib.rs
Expand Up @@ -27,13 +27,18 @@

use std::fmt;

#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

/// Wildcard matcher used to match strings.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Default)]
pub struct WildMatch {
pattern: Vec<State>,
max_questionmarks: usize,
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq)]
struct State {
next_char: Option<char>,
Expand Down

0 comments on commit bbd0cfe

Please sign in to comment.