fn check_url(
    prop: Option<&String>,
    decl_type: &str,
    keyword: &str,
    errors: &mut Vec<Error>,
) -> bool {
    let start_err_len = errors.len();
    check_presence_and_length(MAX_URL_LENGTH, prop, decl_type, keyword, errors);
    if let Some(url) = prop {
        let mut chars_iter = url.chars();
        let mut first_char = true;
        while let Some(c) = chars_iter.next() {
            match c {
                '0'..='9' | 'a'..='z' | '+' | '-' | '.' => first_char = false,
                ':' => {
                    if first_char {
                        // There must be at least one character in the schema
                        errors.push(Error::invalid_field(decl_type, keyword));
                        return false;
                    }
                    // Once a `:` character is found, it must be followed by two `/` characters and
                    // then at least one more character. Note that these sequential calls to
                    // `.next()` without checking the result won't panic because `Chars` implements
                    // `FusedIterator`.
                    match (chars_iter.next(), chars_iter.next(), chars_iter.next()) {
                        (Some('/'), Some('/'), Some(_)) => return start_err_len == errors.len(),
                        _ => {
                            errors.push(Error::invalid_field(decl_type, keyword));
                            return false;
                        }
                    }
                }
                _ => {
                    errors.push(Error::invalid_field(decl_type, keyword));
                    return false;
                }
            }
        }
        // If we've reached here then the string terminated unexpectedly
        errors.push(Error::invalid_field(decl_type, keyword));
    }
    start_err_len == errors.len()
}
// TODO: This should probably be checking with the `url` crate
This should probably be checking with the `url` crate
This should probably be checking with the ` url ` crate
fn check_url(
    prop: Option<&String>,
    decl_type: &str,
    keyword: &str,
    errors: &mut Vec<Error>,
) -> bool {
    let start_err_len = errors.len();
    check_presence_and_length(MAX_URL_LENGTH, prop, decl_type, keyword, errors);
    if let Some(url) = prop {
        let mut chars_iter = url.chars();
        let mut first_char = true;
        while let Some(c) = chars_iter.next() {
            match c {
                '0'..='9' | 'a'..='z' | '+' | '-' | '.' => first_char = false,
                ':' => {
                    if first_char {
                        // There must be at least one character in the schema
                        errors.push(Error::invalid_field(decl_type, keyword));
                        return false;
                    }
                    // Once a `:` character is found, it must be followed by two `/` characters and
                    // then at least one more character. Note that these sequential calls to
                    // `.next()` without checking the result won't panic because `Chars` implements
                    // `FusedIterator`.
                    match (chars_iter.next(), chars_iter.next(), chars_iter.next()) {
                        (Some('/'), Some('/'), Some(_)) => return start_err_len == errors.len(),
                        _ => {
                            errors.push(Error::invalid_field(decl_type, keyword));
                            return false;
                        }
                    }
                }
                _ => {
                    errors.push(Error::invalid_field(decl_type, keyword));
                    return false;
                }
            }
        }
        // If we've reached here then the string terminated unexpectedly
        errors.push(Error::invalid_field(decl_type, keyword));
    }
    start_err_len == errors.len()
}
fn check_url ( prop : Option < & String > , decl_type : & str , keyword : & str , errors : & mut Vec < Error > , ) -> bool { let start_err_len = errors . len ( ) ; check_presence_and_length ( MAX_URL_LENGTH , prop , decl_type , keyword , errors ) ; if let Some ( url ) = prop { let mut chars_iter = url . chars ( ) ; let mut first_char = true ; while let Some ( c ) = chars_iter . next ( ) { match c { '0' ..= '9' | 'a' ..= 'z' | '+' | '-' | '.' => first_char = false , ':' => { if first_char { // There must be at least one character in the schema errors . push ( Error :: invalid_field ( decl_type , keyword ) ) ; return false ; } // Once a `:` character is found, it must be followed by two `/` characters and // then at least one more character. Note that these sequential calls to // `.next()` without checking the result won't panic because `Chars` implements // `FusedIterator`. match ( chars_iter . next ( ) , chars_iter . next ( ) , chars_iter . next ( ) ) { ( Some ( '/' ) , Some ( '/' ) , Some ( _ ) ) => return start_err_len == errors . len ( ) , _ => { errors . push ( Error :: invalid_field ( decl_type , keyword ) ) ; return false ; } } } _ => { errors . push ( Error :: invalid_field ( decl_type , keyword ) ) ; return false ; } } } // If we've reached here then the string terminated unexpectedly errors . push ( Error :: invalid_field ( decl_type , keyword ) ) ; } start_err_len == errors . len ( ) }
TODO: This should probably be checking with the `url` crate
TODO : This should probably be checking with the ` url ` crate
prop
Option<&String>
decl_type
&str
keyword
&str
errors
&mut Vec<Error>
prop
Option<&String>
decl_type
&str
keyword
&str
errors
&mut Vec<Error>