### Wildcard Non-Matching Examples Source: https://docs.rs/wildmatch Illustrates cases where wildcard patterns do not match the input strings. These assertions are expected to be false. ```rust assert!(!WildMatch::new("dog").matches("cat")); ``` ```rust assert!(!WildMatch::new("*d").matches("cat")); ``` ```rust assert!(!WildMatch::new("????").matches("cat")); ``` ```rust assert!(!WildMatch::new("?").matches("cat")); ``` -------------------------------- ### Basic Wildcard Matching Examples Source: https://docs.rs/wildmatch Demonstrates basic usage of the WildMatch struct for matching strings against wildcard patterns. Asserts true for successful matches and false for unsuccessful ones. ```rust assert!(WildMatch::new("cat").matches("cat")); ``` ```rust assert!(WildMatch::new("*cat*").matches("dog_cat_dog")); ``` ```rust assert!(WildMatch::new("c?t").matches("cat")); ``` ```rust assert!(WildMatch::new("c?t").matches("cot")); ``` -------------------------------- ### Successful Pattern Creation Source: https://docs.rs/wildmatch/2.6.1/wildmatch/struct.WildMatchPattern.html These examples show successful compilation when distinct characters are used for multi-character and single-character wildcards. This is the standard way to define a WildMatchPattern. ```rust // ✅ Compiles fine. WildMatchPattern::<'*', '?'>::new(""); ``` ```rust // ✅ Compiles fine. WildMatchPattern::<'*', '?'>::new_case_insensitive(""); ``` -------------------------------- ### Get the Pattern String Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `pattern` method returns the original pattern string used to create the WildMatchPattern. Consecutive multi-wildcards in the original pattern are simplified to a single multi-wildcard in the returned string. ```rust pub fn pattern(&self) -> String ``` -------------------------------- ### Compile-time Error: Identical Wildcards Source: https://docs.rs/wildmatch/2.6.1/wildmatch/struct.WildMatchPattern.html This example demonstrates a compile-time error that occurs when the same character is used for both multi-character and single-character wildcards. The compiler enforces that these must be distinct. ```rust // ❌ Fails to compile: '*' cannot be both wildcards. WildMatchPattern::<'*', '*'>::new(""); ``` ```rust // ❌ Fails to compile: '*' cannot be both wildcards. WildMatchPattern::<'*', '*'>::new_case_insensitive(""); ``` -------------------------------- ### Get the Pattern as a Slice of Characters Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `pattern_chars` method returns the pattern string as a slice of characters. This can be useful for character-level analysis or manipulation of the pattern. ```rust pub fn pattern_chars(&self) -> &[char] ``` -------------------------------- ### Basic Wildcard Matching Source: https://docs.rs/wildmatch/2.6.1/wildmatch/index.html Demonstrates how to use the `WildMatch` struct with default wildcards ('*' and '?') to match strings. ```APIDOC ## WildMatch::new(pattern).matches(text) ### Description Tests a wildcard pattern against an input string. Returns true only when the pattern matches the entirety of the string. ### Method `new` followed by `matches` on `WildMatch` struct. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust assert!(WildMatch::new("cat").matches("cat")); assert!(WildMatch::new("*cat*").matches("dog_cat_dog")); assert!(WildMatch::new("c?t").matches("cat")); assert!(WildMatch::new("c?t").matches("cot")); ``` ### Response #### Success Response (boolean) - `true`: if the pattern matches the string. - `false`: if the pattern does not match the string. #### Response Example ```rust assert!(!WildMatch::new("dog").matches("cat")); assert!(!WildMatch::new("*d").matches("cat")); assert!(!WildMatch::new("????").matches("cat")); assert!(!WildMatch::new("?").matches("cat")); ``` ``` -------------------------------- ### WildMatchPattern::new Source: https://docs.rs/wildmatch/2.6.1/wildmatch/struct.WildMatchPattern.html Constructor with a pattern string for matching. Supports generic type parameters for multi and single character wildcards. ```APIDOC ## WildMatchPattern::new ### Description Constructor with pattern which can be used for matching. ### Signature ```rust pub fn new(pattern: &str) -> WildMatchPattern ``` ### Parameters * `pattern` - &str: The pattern string to use for matching. ``` -------------------------------- ### Create a WildMatchPattern Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html Use the `new` function to construct a WildMatchPattern from a string pattern. This pattern can then be used for matching against input strings. ```rust pub fn new(pattern: &str) -> WildMatchPattern ``` -------------------------------- ### WildMatchPattern::matches Source: https://docs.rs/wildmatch/2.6.1/wildmatch/struct.WildMatchPattern.html Checks if the pattern applies to the given input string. ```APIDOC ## WildMatchPattern::matches ### Description Returns true if pattern applies to the given input string. ### Signature ```rust pub fn matches(&self, input: &str) -> bool ``` ### Parameters * `input` - &str: The string to check against the pattern. ### Returns * bool: `true` if the input string matches the pattern, `false` otherwise. ``` -------------------------------- ### WildMatchPattern::new_case_insensitive Source: https://docs.rs/wildmatch/2.6.1/wildmatch/struct.WildMatchPattern.html Constructor with a pattern string for case-insensitive matching. Supports generic type parameters for multi and single character wildcards. ```APIDOC ## WildMatchPattern::new_case_insensitive ### Description Constructor with pattern which can be used for matching with case-insensitive comparison. ### Signature ```rust pub fn new_case_insensitive(pattern: &str) -> WildMatchPattern ``` ### Parameters * `pattern` - &str: The pattern string to use for case-insensitive matching. ``` -------------------------------- ### Custom Wildcard Characters Source: https://docs.rs/wildmatch/2.6.1/wildmatch/index.html Shows how to use `WildMatchPattern` with custom characters for single and multi-character wildcards. ```APIDOC ## WildMatchPattern::new(pattern).matches(text) ### Description Tests a wildcard pattern against an input string using custom characters for wildcards. Returns true only when the pattern matches the entirety of the string. ### Method `new` followed by `matches` on `WildMatchPattern` struct with generic types for wildcards. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust assert!(WildMatchPattern::<'%', '_'>::new("%cat%").matches("dog_cat_dog")); ``` ### Response #### Success Response (boolean) - `true`: if the pattern matches the string. - `false`: if the pattern does not match the string. #### Response Example ```rust // Example demonstrating a non-match with custom wildcards assert!(!WildMatchPattern::<'%', '_'>::new("%dog").matches("cat_dog")); ``` ``` -------------------------------- ### Clone From Another WildMatchPattern Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `clone_from` method, part of the `Clone` trait implementation, performs copy-assignment from a source WildMatchPattern to the current one. This is an efficient way to update an existing pattern. ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Create a Case-Insensitive WildMatchPattern Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html Use the `new_case_insensitive` function to create a WildMatchPattern that performs case-insensitive matching. This is useful when the case of the input string should not affect the match. ```rust pub fn new_case_insensitive( pattern: &str, ) -> WildMatchPattern ``` -------------------------------- ### WildMatch Pattern Creation Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html Constructs a new WildMatch pattern. The pattern can use '*' for multi-character wildcards and '?' for single-character wildcards. ```APIDOC ## pub fn new(pattern: &str) -> WildMatchPattern ### Description Constructor with pattern which can be used for matching. ### Method `new` ### Parameters #### Path Parameters - **pattern** (str) - Required - The wildcard pattern string. ``` ```APIDOC ## pub fn new_case_insensitive(pattern: &str) -> WildMatchPattern ### Description Constructor with pattern which can be used for matching with case-insensitive comparison. ### Method `new_case_insensitive` ### Parameters #### Path Parameters - **pattern** (str) - Required - The wildcard pattern string. ``` -------------------------------- ### Custom Wildcard Characters Source: https://docs.rs/wildmatch Shows how to use custom characters for single and multi-character wildcards by specifying them in the generic type parameters of WildMatchPattern. ```rust assert!(WildMatchPattern::<'%', '_'>::new("%cat%").matches("dog_cat_dog")); ``` -------------------------------- ### StructuralPartialEq for WildMatchPattern Source: https://docs.rs/wildmatch/2.6.1/wildmatch/struct.WildMatchPattern.html Provides partial equality comparison for WildMatchPattern instances. ```APIDOC ## fn ge(&self, other: &Rhs) -> bool Tests greater than or equal to (for `self` and `other`) and is used by the `>=` operator. ### Method `ge` ### Parameters - **other**: `&Rhs` - The other value to compare against. ### Returns - `bool` - True if `self` is greater than or equal to `other`, false otherwise. ``` -------------------------------- ### WildMatch Pattern Information Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html Methods to retrieve information about the WildMatch pattern. ```APIDOC ## pub fn pattern(&self) -> String ### Description Returns the pattern string. N.B. Consecutive multi-wildcards are simplified to a single multi-wildcard. ### Method `pattern` ``` ```APIDOC ## pub fn pattern_chars(&self) -> &[char] ### Description Returns the pattern string as a slice of chars. ### Method `pattern_chars` ``` ```APIDOC ## pub fn is_case_insensitive(&self) -> bool ### Description Returns if the pattern is case-insensitive. ### Method `is_case_insensitive` ``` -------------------------------- ### Format WildMatchPattern for Debugging Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `fmt` method, part of the `Debug` trait implementation, formats the WildMatchPattern for debugging purposes. This allows for inspecting the pattern's state when printing it. ```rust fn fmt(&self, f: &mut Formatter<'_>) -> Result ``` -------------------------------- ### WildMatchPattern::pattern Source: https://docs.rs/wildmatch/2.6.1/wildmatch/struct.WildMatchPattern.html Returns the pattern string. Consecutive multi-wildcards are simplified to a single multi-wildcard. ```APIDOC ## WildMatchPattern::pattern ### Description Returns the pattern string. N.B. Consecutive multi-wildcards are simplified to a single multi-wildcard. ### Signature ```rust pub fn pattern(&self) -> String ``` ### Returns * String: The pattern string. ``` -------------------------------- ### Compare WildMatchPattern with a String Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `eq` method, part of the `PartialEq<&'a str>` trait implementation, tests for equality between a WildMatchPattern and a string slice. This enables direct comparison using the `==` operator. ```rust fn eq(&self, other: &&'a str) -> bool ``` -------------------------------- ### WildMatch Matching Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html Methods for checking if an input string matches the WildMatch pattern. ```APIDOC ## pub fn matches(&self, input: &str) -> bool ### Description Returns true if pattern applies to the given input string. ### Method `matches` ### Parameters #### Path Parameters - **input** (str) - Required - The string to match against the pattern. ``` -------------------------------- ### Clone a WildMatchPattern Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `clone` method, part of the `Clone` trait implementation, returns a duplicate of the WildMatchPattern. This allows for creating independent copies of the pattern. ```rust fn clone(&self) -> WildMatchPattern ``` -------------------------------- ### Less Than or Equal To Comparison for WildMatchPatterns Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `le` method, part of the `PartialOrd` trait implementation, tests if the first WildMatchPattern is less than or equal to the second. This is used by the `<=` operator. ```rust fn le(&self, other: &Rhs) -> bool ``` -------------------------------- ### WildMatchPattern::pattern_chars Source: https://docs.rs/wildmatch/2.6.1/wildmatch/struct.WildMatchPattern.html Returns the pattern string as a slice of chars. ```APIDOC ## WildMatchPattern::pattern_chars ### Description Returns the pattern string as a slice of chars. ### Signature ```rust pub fn pattern_chars(&self) -> &[char] ``` ### Returns * &[char]: A slice of characters representing the pattern. ``` -------------------------------- ### Compare Two WildMatchPatterns for Equality Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `eq` method, part of the `PartialEq` trait implementation, tests for equality between two WildMatchPatterns. This allows direct comparison using the `==` operator. ```rust fn eq(&self, other: &WildMatchPattern) -> bool ``` -------------------------------- ### Partial Ordering Comparison Source: https://docs.rs/wildmatch/2.6.1/wildmatch/struct.WildMatchPattern.html The `PartialOrd` trait implementation provides methods for comparing `WildMatchPattern` instances. These methods allow for less than, less than or equal to, and greater than comparisons. ```rust fn partial_cmp( &self, other: &WildMatchPattern, ) -> Option ``` ```rust fn lt(&self, other: &Rhs) -> bool ``` ```rust fn le(&self, other: &Rhs) -> bool ``` ```rust fn gt(&self, other: &Rhs) -> bool ``` -------------------------------- ### Check if a String Matches the Pattern Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `matches` method returns true if the pattern associated with the WildMatchPattern applies to the given input string. This is the recommended method for pattern matching. ```rust pub fn matches(&self, input: &str) -> bool ``` -------------------------------- ### Equality Comparison Between WildMatchPatterns Source: https://docs.rs/wildmatch/2.6.1/wildmatch/struct.WildMatchPattern.html This implementation enables equality checks between two `WildMatchPattern` instances using the `==` operator. It determines if two patterns are identical. ```rust fn eq(&self, other: &WildMatchPattern) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Partial Equality Comparison with String Slice Source: https://docs.rs/wildmatch/2.6.1/wildmatch/struct.WildMatchPattern.html This implementation allows comparing a `WildMatchPattern` directly with a string slice (`&str`) using the equality operator (`==`). It checks if the pattern matches the given string. ```rust fn eq(&self, other: &&'a str) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Partial Comparison of WildMatchPatterns Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `partial_cmp` method, part of the `PartialOrd` trait implementation, returns an ordering between two WildMatchPatterns if one exists. This enables partial ordering comparisons. ```rust fn partial_cmp( &self, other: &WildMatchPattern, ) -> Option ``` -------------------------------- ### Not Equal WildMatchPattern with a String Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `ne` method, part of the `PartialEq<&'a str>` trait implementation, tests for inequality between a WildMatchPattern and a string slice. This enables comparison using the `!=` operator. ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Greater Than or Equal To Comparison for WildMatchPatterns Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `ge` method, part of the `PartialOrd` trait implementation, tests if the first WildMatchPattern is greater than or equal to the second. This is used by the `>=` operator. ```rust fn ge(&self, other: &Rhs) -> bool ``` -------------------------------- ### Check if a String Matches the Pattern (Deprecated) Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `is_match` method is deprecated since version 2.0.0 and should be replaced with the `matches` method for checking if a pattern applies to an input string. ```rust pub fn is_match(&self, input: &str) -> bool ``` -------------------------------- ### Less Than Comparison for WildMatchPatterns Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `lt` method, part of the `PartialOrd` trait implementation, tests if the first WildMatchPattern is less than the second. This is used by the `<` operator. ```rust fn lt(&self, other: &Rhs) -> bool ``` -------------------------------- ### WildMatchPattern::is_case_insensitive Source: https://docs.rs/wildmatch/2.6.1/wildmatch/struct.WildMatchPattern.html Returns whether the pattern is case-insensitive. ```APIDOC ## WildMatchPattern::is_case_insensitive ### Description Returns if the pattern is case-insensitive. ### Signature ```rust pub fn is_case_insensitive(&self) -> bool ``` ### Returns * bool: `true` if the pattern is case-insensitive, `false` otherwise. ``` -------------------------------- ### WildMatch Struct Definition Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html This shows the structure of the WildMatch type, which is used for pattern matching with wildcards. It is a private struct, and its functionality is accessed through associated methods. ```rust pub struct WildMatch { /* private fields */ } ``` -------------------------------- ### Greater Than Comparison for WildMatchPatterns Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `gt` method, part of the `PartialOrd` trait implementation, tests if the first WildMatchPattern is greater than the second. This is used by the `>` operator. ```rust fn gt(&self, other: &Rhs) -> bool ``` -------------------------------- ### Default WildMatchPattern Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `default` function, part of the `Default` trait implementation, returns the default value for a WildMatchPattern. This is typically an empty pattern or a pattern with default wildcard characters. ```rust fn default() -> WildMatchPattern ``` -------------------------------- ### WildMatch Type Alias Definition Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html This defines the WildMatch type alias, which is a shorthand for WildMatchPattern with '*' as the multi-character wildcard and '?' as the single-character wildcard. ```rust pub type WildMatch = WildMatchPattern<'*', '?'>; ``` -------------------------------- ### Check if the Pattern is Case-Insensitive Source: https://docs.rs/wildmatch/2.6.1/wildmatch/type.WildMatch.html The `is_case_insensitive` method returns a boolean indicating whether the WildMatchPattern was created with case-insensitive matching enabled. ```rust pub fn is_case_insensitive(&self) -> bool ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.