pub fn new(template: &str) -> UriTemplate {
        let mut components = Vec::new();
        let mut buf = String::new();
        let mut in_varlist = false;

        for ch in template.chars() {
            if in_varlist && ch == '}' {
                components.push(parse_varlist(&buf));
                buf = String::new();
                in_varlist = false;
                continue;
            }
            if !in_varlist && ch == '{' {
                if buf.len() > 0 {
                    components.push(TemplateComponent::Literal(buf));
                    buf = String::new();
                }
                in_varlist = true;
                continue;
            }
            buf.push(ch);
        }

        if buf.len() > 0 {
            components.push(TemplateComponent::Literal(buf));
        }

        UriTemplate {
            components: components,
            vars: HashMap::new()
        }
    }
/// Creates a new URI Template from the given template string.
///
/// Example
/// -------
/// ```ignore
/// let t = UriTemplate::new("http://example.com/{name}");
/// ```
Creates a new URI Template from the given template string.
Example


Creates a new URI Template from the given template string . Example
pub fn new(template: &str) -> UriTemplate {
        let mut components = Vec::new();
        let mut buf = String::new();
        let mut in_varlist = false;
        for ch in template.chars() {
            if in_varlist && ch == '}' {
                components.push(parse_varlist(&buf));
                buf = String::new();
                in_varlist = false;
                continue;
            }
            if !in_varlist && ch == '{' {
                if buf.len() > 0 {
                    components.push(TemplateComponent::Literal(buf));
                    buf = String::new();
                }
                in_varlist = true;
                continue;
            }
            buf.push(ch);
        }
        if buf.len() > 0 {
            components.push(TemplateComponent::Literal(buf));
        }
        UriTemplate {
            components: components,
            vars: HashMap::new()
        }
    }
pub fn new ( template : & str ) -> UriTemplate { let mut components = Vec :: new ( ) ; let mut buf = String :: new ( ) ; let mut in_varlist = false ; for ch in template . chars ( ) { if in_varlist && ch == '}' { components . push ( parse_varlist ( & buf ) ) ; buf = String :: new ( ) ; in_varlist = false ; continue ; } if ! in_varlist && ch == '{' { if buf . len ( ) > 0 { components . push ( TemplateComponent :: Literal ( buf ) ) ; buf = String :: new ( ) ; } in_varlist = true ; continue ; } buf . push ( ch ) ; } if buf . len ( ) > 0 { components . push ( TemplateComponent :: Literal ( buf ) ) ; } UriTemplate { components : components , vars : HashMap :: new ( ) } }
Creates a new URI Template from the given template string.
Creates a new URI Template from the given template string .
template
&str
template
&str