// Convert the route into chunks
// Empty will be handled as `/`
Convert the route into chunks
Empty will be handled as `/`
Convert the route into chunks Empty will be handled as ` / `
fn parse_url<'u>(token: &'u LitStr, url: &'u str) -> UrlParams<'u> {
    let items = if url.contains('{') {
        // Handles routes with arguments
        url.match_indices('{')
            .zip(url.match_indices('}'))
            .fold(
                (0, Vec::with_capacity(16)),
                |(last, mut parts), ((start, _), (end, _))| {
                    // Converts any route data between the last and the current argument
                    parts.extend(
                        (&url[last..start])
                            .split('/')
                            .filter(|p| !p.is_empty())
                            .map(|value| UrlParam::Chunk { value }),
                    );
                    // Grabs the name of the current argument
                    parts.push(UrlParam::Param {
                        key: &url[(start + 1)..end],
                    });
                    (end + 1, parts)
                },
            )
            .1
    } else {
        // Handles routes without arguments
        url.split('/')
            .filter(|p| !p.is_empty())
            .map(|value| UrlParam::Chunk { value })
            .collect()
    };
    UrlParams { token, items }
}
fn parse_url < ' u > ( token : & ' u LitStr , url : & ' u str ) -> UrlParams < ' u > { let items = if url . contains ( '{' ) { // Handles routes with arguments url . match_indices ( '{' ) . zip ( url . match_indices ( '}' ) ) . fold ( ( 0 , Vec :: with_capacity ( 16 ) ) , | ( last , mut parts ) , ( ( start , _ ) , ( end , _ ) ) | { // Converts any route data between the last and the current argument parts . extend ( ( & url [ last .. start ] ) . split ( '/' ) . filter ( | p | ! p . is_empty ( ) ) . map ( | value | UrlParam :: Chunk { value } ) , ) ; // Grabs the name of the current argument parts . push ( UrlParam :: Param { key : & url [ ( start + 1 ) .. end ] , } ) ; ( end + 1 , parts ) } , ) . 1 } else { // Handles routes without arguments url . split ( '/' ) . filter ( | p | ! p . is_empty ( ) ) . map ( | value | UrlParam :: Chunk { value } ) . collect ( ) } ; UrlParams { token , items } }
Convert the route into chunks
Empty will be handled as `/`
Convert the route into chunks Empty will be handled as ` / `
token
&'u LitStr
url
&'u str