pub fn matches(&self, path: &str) -> bool {
        // ex: [ "", "food", ":food_type" ]
        let defined_segments = self
            .route_definition
            .split("/")
            .filter(|segment| segment.len() > 0)
            .collect::<Vec<&str>>();

        // ex: [ "", "food", "tacos" ]
        let incoming_segments = path
            .split("/")
            .filter(|segment| segment.len() > 0)
            .collect::<Vec<&str>>();

        if defined_segments.len() != incoming_segments.len() {
            return false;
        }

        for (index, defined_segment) in defined_segments.iter().enumerate() {
            if defined_segment.len() == 0 {
                continue;
            }

            let mut chars = defined_segment.chars();

            let first_char = chars.next().unwrap();

            // ex: ":food_type"
            if first_char == ':' {
                let param_name = chars.collect::<String>();
                // ex: ParamType::String
                let param_type = self.param_types.get(&param_name).unwrap();

                let incoming_param_value = incoming_segments[index];

                // Make sure that it is possible to convert the String that the user provided
                // into the parameter type that we expect (u32, u8, i8, etc)
                match param_type {
                    ParamType::U32 => {
                        if incoming_param_value.parse::<u32>().is_err() {
                            return false;
                        }
                    }
                    ParamType::U64 => {
                        if incoming_param_value.parse::<u64>().is_err() {
                            return false;
                        }
                    }
                };
            }
        }

        true
    }
/// Determine whether or not our route matches a provided path.
///
/// # Example
///
/// ```rust,ignore
/// route.matches("/food/tacos");
/// ```
Determine whether or not our route matches a provided path.
Determine whether or not our route matches a provided path .
pub fn matches(&self, path: &str) -> bool {
        // ex: [ "", "food", ":food_type" ]
        let defined_segments = self
            .route_definition
            .split("/")
            .filter(|segment| segment.len() > 0)
            .collect::<Vec<&str>>();
        // ex: [ "", "food", "tacos" ]
        let incoming_segments = path
            .split("/")
            .filter(|segment| segment.len() > 0)
            .collect::<Vec<&str>>();
        if defined_segments.len() != incoming_segments.len() {
            return false;
        }
        for (index, defined_segment) in defined_segments.iter().enumerate() {
            if defined_segment.len() == 0 {
                continue;
            }
            let mut chars = defined_segment.chars();
            let first_char = chars.next().unwrap();
            // ex: ":food_type"
            if first_char == ':' {
                let param_name = chars.collect::<String>();
                // ex: ParamType::String
                let param_type = self.param_types.get(&param_name).unwrap();
                let incoming_param_value = incoming_segments[index];
                // Make sure that it is possible to convert the String that the user provided
                // into the parameter type that we expect (u32, u8, i8, etc)
                match param_type {
                    ParamType::U32 => {
                        if incoming_param_value.parse::<u32>().is_err() {
                            return false;
                        }
                    }
                    ParamType::U64 => {
                        if incoming_param_value.parse::<u64>().is_err() {
                            return false;
                        }
                    }
                };
            }
        }
        true
    }
pub fn matches ( & self , path : & str ) -> bool { // ex: [ "", "food", ":food_type" ] let defined_segments = self . route_definition . split ( " " ) . filter ( | segment | segment . len ( ) > 0 ) . collect :: < Vec < & str > > ( ) ; // ex: [ "", "food", "tacos" ] let incoming_segments = path . split ( " " ) . filter ( | segment | segment . len ( ) > 0 ) . collect :: < Vec < & str > > ( ) ; if defined_segments . len ( ) != incoming_segments . len ( ) { return false ; } for ( index , defined_segment ) in defined_segments . iter ( ) . enumerate ( ) { if defined_segment . len ( ) == 0 { continue ; } let mut chars = defined_segment . chars ( ) ; let first_char = chars . next ( ) . unwrap ( ) ; // ex: ":food_type" if first_char == ':' { let param_name = chars . collect :: < String > ( ) ; // ex: ParamType::String let param_type = self . param_types . get ( & param_name ) . unwrap ( ) ; let incoming_param_value = incoming_segments [ index ] ; // Make sure that it is possible to convert the String that the user provided // into the parameter type that we expect (u32, u8, i8, etc) match param_type { ParamType :: U32 => { if incoming_param_value . parse :: < u32 > ( ) . is_err ( ) { return false ; } } ParamType :: U64 => { if incoming_param_value . parse :: < u64 > ( ) . is_err ( ) { return false ; } } } ; } } true }
Determine whether or not our route matches a provided path.
Determine whether or not our route matches a provided path .
&self
path
&str
&self
path
&str
example
```rust,ignore
route.matches("/food/tacos");
```
` ` ` rust ignore route . matches ( " / food / tacos " ) ; ` ` `