Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 //! Match strings against a simple wildcard pattern.
2 //! Tests a wildcard pattern `p` against an input string `s`. Returns true only when `p` matches the entirety of `s`.
3 //!
4 //! See also the example described on [wikipedia](https://en.wikipedia.org/wiki/Matching_wildcards) for matching wildcards.
5 //!
6 //! No escape characters are defined.
7 //!
8 //! - `?` matches exactly one occurrence of any character.
9 //! - `*` matches arbitrary many (including zero) occurrences of any character.
10 //!
11 //! Examples matching wildcards:
12 //! ``` rust
13 //! # extern crate wildmatch; use wildmatch::WildMatch;
14 //! assert!(WildMatch::new("cat").matches("cat"));
15 //! assert!(WildMatch::new("*cat*").matches("dog_cat_dog"));
16 //! assert!(WildMatch::new("c?t").matches("cat"));
17 //! assert!(WildMatch::new("c?t").matches("cot"));
18 //! ```
19 //! Examples not matching wildcards:
20 //! ``` rust
21 //! # extern crate wildmatch; use wildmatch::WildMatch;
22 //! assert!(!WildMatch::new("dog").matches("cat"));
23 //! assert!(!WildMatch::new("*d").matches("cat"));
24 //! assert!(!WildMatch::new("????").matches("cat"));
25 //! assert!(!WildMatch::new("?").matches("cat"));
26 //! ```
27 //!
28 //! You can specify custom `char` values for the single and multi-character
29 //! wildcards. For example, to use `%` as the multi-character wildcard and
30 //! `_` as the single-character wildcard:
31 //! ```rust
32 //! # extern crate wildmatch; use wildmatch::WildMatchPattern;
33 //! assert!(WildMatchPattern::<'%', '_'>::new("%cat%").matches("dog_cat_dog"));
34 //! ```
35
36 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/;
37
38 #[cfg(feature = "serde")]
39 use serderust-analyzer cargo serde 1.0.193 crate/::{Deserializerust-analyzer cargo serde 1.0.193 de/Deserialize#, Serializerust-analyzer cargo serde 1.0.193 ser/Serialize#};
40
41 /// A wildcard matcher using `*` as the multi-character wildcard and `?` as
42 /// the single-character wildcard.
43 pub type WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch# = WildMatchPatternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#<'*', '?'>;
44
45 /// Wildcard matcher used to match strings.
46 ///
47 /// `MULTI_WILDCARD` is the character used to represent a
48 /// multiple-character wildcard (e.g., `*`), and `SINGLE_WILDCARD` is the
49 /// character used to represent a single-character wildcard (e.g., `?`).
50 ///
51 /// # Panics
52 ///
53 /// Panics at compile time if both wildcard characters are identical.
54 ///
55 /// # Examples
56 ///
57 /// ```compile_fail
58 /// # use wildmatch::WildMatchPattern;
59 /// // ❌ Fails to compile: '*' cannot be both wildcards.
60 /// WildMatchPattern::<'*', '*'>::new("");
61 /// ```
62 ///
63 /// ```compile_fail
64 /// # use wildmatch::WildMatchPattern;
65 /// // ❌ Fails to compile: '*' cannot be both wildcards.
66 /// WildMatchPattern::<'*', '*'>::new_case_insensitive("");
67 /// ```
68 ///
69 /// ```
70 /// # use wildmatch::WildMatchPattern;
71 /// // ✅ Compiles fine.
72 /// WildMatchPattern::<'*', '?'>::new("");
73 /// ```
74 ///
75 /// ```
76 /// # use wildmatch::WildMatchPattern;
77 /// // ✅ Compiles fine.
78 /// WildMatchPattern::<'*', '?'>::new_case_insensitive("");
79 /// ```
80 #[cfg_attr(feature = "serde", derive(Serializerust-analyzer cargo serde_derive 1.0.193 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.193 Deserialize:))]
81 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
82 pub struct WildMatchPatternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#<const MULTI_WILDCARD: char, const SINGLE_WILDCARD: char> {
83 patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<char>,
84 case_insensitiverust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#case_insensitive.: bool,
85 }
86
87 impl<const MULTI_WILDCARD: char, const SINGLE_WILDCARD: char> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#
88 for WildMatchPatternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#<MULTI_WILDCARD, SINGLE_WILDCARD>
89 {
90 fn fmtrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
91 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Write#;
92 for c in &self.patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern. {
93 f.write_charrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'_>`][Write]write_char().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
94 }
95 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
96 }
97 }
98
99 impl<const MULTI_WILDCARD: char, const SINGLE_WILDCARD: char>
100 WildMatchPatternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#<MULTI_WILDCARD, SINGLE_WILDCARD>
101 {
102 const WILDCARDS_DIFFERrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]WILDCARDS_DIFFER.: () = assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
103 MULTI_WILDCARD != SINGLE_WILDCARD,
104 "single and multi wildcards cannot be the same"
105 );
106
107 /// Constructor with pattern which can be used for matching.
108 pub fn newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().(pattern: &str) -> WildMatchPatternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#<MULTI_WILDCARD, SINGLE_WILDCARD> {
109 #[allow(clippy::let_unit_value)]
110 let _ = Selfrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]::WILDCARDS_DIFFERrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]WILDCARDS_DIFFER.;
111
112 let mut simplified: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<char> = pattern.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
113 let mut new_len = simplified.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().();
114 let mut wildcard_count = 0;
115
116 for idx in (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#simplified.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()).revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() {
117 if simplified[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().idx]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().MULTI_WILDCARD {
118 wildcard_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
119 } else {
120 if wildcard_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().1 {
121 new_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().wildcard_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1;
122 simplified[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut()..rotate_leftrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]rotate_left().(wildcard_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1);
123 }
124 wildcard_count = 0;
125 }
126 }
127 if wildcard_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().1 {
128 new_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().wildcard_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1;
129 simplified.rotate_leftrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]rotate_left().(wildcard_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1);
130 }
131
132 simplified.truncaterust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]truncate().(new_len);
133
134 Selfrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`] {
135 patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern.: simplified,
136 case_insensitiverust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#case_insensitive.: false,
137 }
138 }
139
140 /// Constructor with pattern which can be used for matching with case-insensitive comparison.
141 pub fn new_case_insensitiverust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new_case_insensitive().(
142 pattern: &str,
143 ) -> WildMatchPatternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#<MULTI_WILDCARD, SINGLE_WILDCARD> {
144 let mut m = Selfrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().(pattern);
145 m.case_insensitiverust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#case_insensitive. = true;
146 m
147 }
148
149 #[deprecated(since = "2.0.0", note = "use `matches` instead")]
150 pub fn is_matchrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]is_match().(&self, input: &str) -> bool {
151 self.matchesrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]matches().(input)
152 }
153
154 /// Returns true if pattern applies to the given input string
155 pub fn matchesrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]matches().(&self, input: &str) -> bool {
156 if self.patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
157 return input.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().();
158 }
159 let mut input_chars = input.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().();
160
161 let mut pattern_idx = 0;
162 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mut input_char) = input_chars.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]next().() {
163 const NONErust-analyzer cargo wildmatch 2.6.1 NONE.: usize = usize::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]MAX.;
164 let mut start_idx = NONErust-analyzer cargo wildmatch 2.6.1 NONE.;
165 let mut matched = "".charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().();
166
167 loop {
168 if pattern_idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().self.patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() && self.patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().pattern_idx]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().MULTI_WILDCARD {
169 start_idx = pattern_idx;
170 matched = input_chars.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Clone]clone().();
171 pattern_idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
172 } else if pattern_idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().self.patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()
173 && (self.patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().pattern_idx]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().SINGLE_WILDCARD
174 || self.patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().pattern_idx]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().input_char
175 || (self.case_insensitiverust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#case_insensitive.
176 && self.patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().pattern_idx]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..to_lowercaserust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]to_lowercase().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>()
177 ==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A1>`][`PartialEq<Vec<U, A2>>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/partial_eq/impl#[`Vec<T, A1>`][`PartialEq<Vec<U, A2>>`]eq().input_char.to_lowercaserust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]to_lowercase().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>()))
178 {
179 pattern_idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
180 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(next_char) = input_chars.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]next().() {
181 input_char = next_char;
182 } else {
183 break;
184 }
185 } else if start_idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().NONErust-analyzer cargo wildmatch 2.6.1 NONE. {
186 pattern_idx = start_idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1;
187 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(next_char) = matched.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]next().() {
188 input_char = next_char;
189 } else {
190 break;
191 }
192 input_chars = matched.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Clone]clone().();
193 } else {
194 return false;
195 }
196 }
197 }
198
199 while pattern_idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().self.patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() && self.patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().pattern_idx]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().MULTI_WILDCARD {
200 pattern_idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
201 }
202
203 // If we have reached the end of both the pattern and the text, the pattern matches the text.
204 pattern_idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().self.patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()
205 }
206
207 /// Returns the pattern string.
208 /// N.B. Consecutive multi-wildcards are simplified to a single multi-wildcard.
209 pub fn patternrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]pattern().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
210 self.patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>()
211 }
212
213 /// Returns the pattern string as a slice of chars.
214 pub fn pattern_charsrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]pattern_chars().(&self) -> &[char] {
215 &self.patternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#pattern.
216 }
217
218 /// Returns if the pattern is case-insensitive.
219 pub fn is_case_insensitiverust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]is_case_insensitive().(&self) -> bool {
220 self.case_insensitiverust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#case_insensitive.
221 }
222 }
223
224 impl<'a, const MULTI_WILDCARD: char, const SINGLE_WILDCARD: char> PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<&'a str>
225 for WildMatchPatternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#<MULTI_WILDCARD, SINGLE_WILDCARD>
226 {
227 fn eqrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`][`PartialEq<&'a str>`]eq().(&self, &other: &&'a str) -> bool {
228 self.matchesrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]matches().(other)
229 }
230 }
231
232 #[cfg(test)]
233 mod testsrust-analyzer cargo wildmatch 2.6.1 tests/ {
234 use superrust-analyzer cargo wildmatch 2.6.1 crate/::*;
235 use ntestrust-analyzer cargo ntest 0.9.3 crate/::assert_falserust-analyzer cargo ntest 0.9.3 assert_false!;
236 use ntestrust-analyzer cargo ntest 0.9.3 crate/::test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:;
237 use randrust-analyzer cargo rand 0.8.5 crate/::{distributionsrust-analyzer cargo rand 0.8.5 distributions/::Alphanumericrust-analyzer cargo rand 0.8.5 distributions/other/Alphanumeric#, Rngrust-analyzer cargo rand 0.8.5 rng/Rng#};
238
239 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
240 fn is_match_randomrust-analyzer cargo wildmatch 2.6.1 tests/is_match_random().() {
241 const PATTERN_LENrust-analyzer cargo wildmatch 2.6.1 tests/PATTERN_LEN.: usize = 100;
242
243 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1_000 {
244 let mut rng = randrust-analyzer cargo rand 0.8.5 crate/::thread_rngrust-analyzer cargo rand 0.8.5 rngs/thread/thread_rng().();
245 let mut pattern: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# = randrust-analyzer cargo rand 0.8.5 crate/::thread_rngrust-analyzer cargo rand 0.8.5 rngs/thread/thread_rng().()
246 .sample_iterrust-analyzer cargo rand 0.8.5 rng/Rng#sample_iter().(&Alphanumericrust-analyzer cargo rand 0.8.5 distributions/other/Alphanumeric#)
247 .takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(PATTERN_LENrust-analyzer cargo wildmatch 2.6.1 tests/PATTERN_LEN.)
248 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(char::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/convert/impl#[char][`From<u8>`]from().)
249 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
250 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#rng.gen_rangerust-analyzer cargo rand 0.8.5 rng/Rng#gen_range().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#15) {
251 let idx = rng.gen_rangerust-analyzer cargo rand 0.8.5 rng/Rng#gen_range().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#PATTERN_LENrust-analyzer cargo wildmatch 2.6.1 tests/PATTERN_LEN.);
252 pattern.replace_rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]replace_range().(idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1, "?")
253 }
254 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#rng.gen_rangerust-analyzer cargo rand 0.8.5 rng/Rng#gen_range().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#15) {
255 let idx = rng.gen_rangerust-analyzer cargo rand 0.8.5 rng/Rng#gen_range().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#PATTERN_LENrust-analyzer cargo wildmatch 2.6.1 tests/PATTERN_LEN.);
256 pattern.replace_rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]replace_range().(idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1, "*")
257 }
258 let m = WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().(&pattern);
259 for pattern_idx in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#rng.gen_rangerust-analyzer cargo rand 0.8.5 rng/Rng#gen_range().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1_000) {
260 let mut input = pattern.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().();
261 for (i, c) in pattern.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
262 let idx = pattern.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1;
263 if c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'?' {
264 let rand_char: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# = randrust-analyzer cargo rand 0.8.5 crate/::thread_rngrust-analyzer cargo rand 0.8.5 rngs/thread/thread_rng().()
265 .sample_iterrust-analyzer cargo rand 0.8.5 rng/Rng#sample_iter().(&Alphanumericrust-analyzer cargo rand 0.8.5 distributions/other/Alphanumeric#)
266 .takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(1)
267 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(char::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/convert/impl#[char][`From<u8>`]from().)
268 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
269 input.replace_rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]replace_range().(idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1, &rand_char)
270 }
271 if c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'*' {
272 let rand_char: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# = randrust-analyzer cargo rand 0.8.5 crate/::thread_rngrust-analyzer cargo rand 0.8.5 rngs/thread/thread_rng().()
273 .sample_iterrust-analyzer cargo rand 0.8.5 rng/Rng#sample_iter().(&Alphanumericrust-analyzer cargo rand 0.8.5 distributions/other/Alphanumeric#)
274 .takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(rng.gen_rangerust-analyzer cargo rand 0.8.5 rng/Rng#gen_range().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#15))
275 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(char::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/convert/impl#[char][`From<u8>`]from().)
276 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
277 input.replace_rangerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]replace_range().(idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1, &rand_char)
278 }
279 }
280 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
281 m.matchesrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]matches().(&input),
282 "Pattern ({}): {} doesn't match input: {}",
283 pattern_idx,
284 pattern,
285 input
286 );
287 }
288 }
289 }
290
291 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("**")]
292 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*")]
293 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*?*")]
294 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("c*")]
295 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("c?*")]
296 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("???")]
297 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("c?t")]
298 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("cat")]
299 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*cat")]
300 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("cat*")]
301 fn is_match(pattern: &str) {
302 let m = WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().(pattern);
303 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(m.matchesrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]matches().("cat"));
304 }
305
306 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("CAT", "cat")]
307 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("CAT", "CAT")]
308 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("CA?", "Cat")]
309 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("C*", "cAt")]
310 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("C?*", "cAT")]
311 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("C**", "caT")]
312 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("КОТ", "кот", name = "cyrillic_lower")]
313 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("КОТ", "КОТ", name = "cyrillic_upper")]
314 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("КО?", "Кот", name = "cyrillic_mixed1")]
315 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("К*", "кОт", name = "cyrillic_mixed2")]
316 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("К?*", "кОТ", name = "cyrillic_mixed3")]
317 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("К**", "коТ", name = "cyrillic_mixed4")]
318 fn is_match_case_insensitive(pattern: &str, input: &str) {
319 let m = WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::new_case_insensitiverust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new_case_insensitive().(pattern);
320 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(m.matchesrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]matches().(input));
321 }
322
323 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*d*")]
324 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*d")]
325 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("d*")]
326 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*c")]
327 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("?")]
328 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("??")]
329 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("????")]
330 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("?????")]
331 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*????")]
332 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("cats")]
333 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("cat?")]
334 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("cacat")]
335 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("cat*dog")]
336 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("CAT")]
337 fn no_match(pattern: &str) {
338 let m = WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().(pattern);
339 assert_falserust-analyzer cargo ntest 0.9.3 assert_false!!(m.matchesrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]matches().("cat"));
340 }
341
342 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("1", "")]
343 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("?", "")]
344 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("?", "11")]
345 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*1?", "123")]
346 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*12", "122")]
347 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("cat?", "wildcats")]
348 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("cat*", "wildcats")]
349 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*x*", "wildcats")]
350 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*a", "wildcats")]
351 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("", "wildcats")]
352 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:(" ", "wildcats")]
353 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:(" ", "\n")]
354 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:(" ", "\t", name = "whitespaceMismatch")]
355 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("???", "wildcats")]
356 fn no_match_long(pattern: &str, expected: &str) {
357 let m = WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().(pattern);
358 assert_falserust-analyzer cargo ntest 0.9.3 assert_false!!(m.matchesrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]matches().(expected))
359 }
360
361 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*", "")]
362 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*", "1")]
363 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("?", "1")]
364 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*121", "12121")]
365 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("?*3", "111333")]
366 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*113", "1113")]
367 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*113", "113")]
368 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*113", "11113")]
369 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*113", "111113")]
370 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*???a", "bbbba")]
371 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*???a", "bbbbba")]
372 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*???a", "bbbbbba")]
373 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*o?a*", "foobar")]
374 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*ooo?ar", "foooobar")]
375 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*o?a*r", "foobar")]
376 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*cat*", "d&(*og_cat_dog")]
377 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*?*", "d&(*og_cat_dog")]
378 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*a*", "d&(*og_cat_dog")]
379 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("a*b", "a*xb")]
380 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*", "*")]
381 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*", "?")]
382 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("?", "?")]
383 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("wildcats", "wildcats")]
384 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("wild*cats", "wild?cats")]
385 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("wi*ca*s", "wildcats")]
386 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("wi*ca?s", "wildcats")]
387 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*o?", "hog_cat_dog")]
388 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*o?", "cat_dog")]
389 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*at_dog", "cat_dog")]
390 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:(" ", " ")]
391 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("* ", "\n ")]
392 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("\n", "\n", name = "special_chars")]
393 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*32", "432")]
394 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*32", "332")]
395 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*332", "332")]
396 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*32", "32")]
397 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*32", "3232")]
398 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*32", "3232332")]
399 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*?2", "332")]
400 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*?2", "3332")]
401 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("33*", "333")]
402 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("da*da*da*", "daaadabadmanda")]
403 #[test_caserust-analyzer cargo ntest_test_cases 0.9.3 test_case:("*?", "xx")]
404 fn match_long(pattern: &str, expected: &str) {
405 let m = WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().(pattern);
406 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
407 m.matchesrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]matches().(expected),
408 "Expected pattern {} to match {}",
409 pattern,
410 expected
411 );
412 }
413
414 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
415 fn complex_patternrust-analyzer cargo wildmatch 2.6.1 tests/complex_pattern().() {
416 const TEXTrust-analyzer cargo wildmatch 2.6.1 tests/TEXT.: &str = "Lorem ipsum dolor sit amet, \
417 consetetur sadipscing elitr, sed diam nonumy eirmod tempor \
418 invidunt ut labore et dolore magna aliquyam erat, sed diam \
419 voluptua. At vero eos et accusam et justo duo dolores et ea \
420 rebum. Stet clita kasd gubergren, no sea takimata sanctus est \
421 Lorem ipsum dolor sit amet.";
422 const COMPLEX_PATTERNrust-analyzer cargo wildmatch 2.6.1 tests/COMPLEX_PATTERN.: &str = "Lorem?ipsum*dolore*ea* ?????ata*.";
423 let m = WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().(COMPLEX_PATTERNrust-analyzer cargo wildmatch 2.6.1 tests/COMPLEX_PATTERN.);
424 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(m.matchesrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]matches().(TEXTrust-analyzer cargo wildmatch 2.6.1 tests/TEXT.));
425 }
426
427 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
428 fn complex_pattern_alternative_wildcardsrust-analyzer cargo wildmatch 2.6.1 tests/complex_pattern_alternative_wildcards().() {
429 const TEXTrust-analyzer cargo wildmatch 2.6.1 tests/TEXT.: &str = "Lorem ipsum dolor sit amet, \
430 consetetur sadipscing elitr, sed diam nonumy eirmod tempor \
431 invidunt ut labore et dolore magna aliquyam erat, sed diam \
432 voluptua. At vero eos et accusam et justo duo dolores et ea \
433 rebum. Stet clita kasd gubergren, no sea takimata sanctus est \
434 Lorem ipsum dolor sit amet.";
435 const COMPLEX_PATTERNrust-analyzer cargo wildmatch 2.6.1 tests/COMPLEX_PATTERN.: &str = "Lorem_ipsum%dolore%ea% _____ata%.";
436 let m = WildMatchPatternrust-analyzer cargo wildmatch 2.6.1 WildMatchPattern#::<'%', '_'>::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().(COMPLEX_PATTERNrust-analyzer cargo wildmatch 2.6.1 tests/COMPLEX_PATTERN.);
437 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(m.matchesrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]matches().(TEXTrust-analyzer cargo wildmatch 2.6.1 tests/TEXT.));
438 }
439
440 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
441 fn compare_via_equalrust-analyzer cargo wildmatch 2.6.1 tests/compare_via_equal().() {
442 let m = WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("c?*");
443 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(m == "cat");
444 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(m == "car");
445 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(m != "dog");
446 }
447
448 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
449 fn compare_emptyrust-analyzer cargo wildmatch 2.6.1 tests/compare_empty().() {
450 let m: WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch# = WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("");
451 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(m != "bar");
452 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(m == "");
453 }
454
455 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
456 fn compare_defaultrust-analyzer cargo wildmatch 2.6.1 tests/compare_default().() {
457 let m: WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch# = Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`][Default]default().();
458 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(m == "");
459 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(m != "bar");
460 }
461
462 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
463 fn compare_wild_matchrust-analyzer cargo wildmatch 2.6.1 tests/compare_wild_match().() {
464 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::defaultrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`][Default]default().(), WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().(""));
465 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("abc"), WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("abc"));
466 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("a*bc"), WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("a*bc"));
467 assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("abc"), WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("a*bc"));
468 assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!(WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("a*bc"), WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("a?bc"));
469 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("a***c"), WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("a*c"));
470 }
471
472 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
473 fn print_stringrust-analyzer cargo wildmatch 2.6.1 tests/print_string().() {
474 let m = WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("Foo/Bar");
475 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("Foo/Bar", m.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
476 }
477
478 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
479 fn to_string_frust-analyzer cargo wildmatch 2.6.1 tests/to_string_f().() {
480 let m = WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("F");
481 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("F", m.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
482 }
483
484 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
485 fn to_string_with_starrust-analyzer cargo wildmatch 2.6.1 tests/to_string_with_star().() {
486 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("a*bc", WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("a*bc").to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
487 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("a*bc", WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("a**bc").to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
488 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("a*bc*", WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("a*bc*").to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
489 }
490
491 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
492 fn to_string_with_question_signrust-analyzer cargo wildmatch 2.6.1 tests/to_string_with_question_sign().() {
493 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("a?bc", WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("a?bc").to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
494 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("a??bc", WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("a??bc").to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
495 }
496
497 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
498 fn to_string_emptyrust-analyzer cargo wildmatch 2.6.1 tests/to_string_empty().() {
499 let m = WildMatchrust-analyzer cargo wildmatch 2.6.1 WildMatch#::newrust-analyzer cargo wildmatch 2.6.1 impl#[`WildMatchPattern<MULTI_WILDCARD, SINGLE_WILDCARD>`]new().("");
500 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("", m.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
501 }
502 }