style: Make starts_with_ignore_ascii_case not lie if the strings are the same length.

This commit is contained in:
Emilio Cobos Álvarez 2017-07-08 19:41:28 +02:00
parent d8a22d8bd7
commit 9e00efc8a5
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 7 additions and 1 deletions

View file

@ -148,6 +148,6 @@ pub fn str_join<I, T>(strs: I, join: &str) -> String
/// Returns true if a given string has a given prefix with case-insensitive match.
pub fn starts_with_ignore_ascii_case(string: &str, prefix: &str) -> bool {
string.len() > prefix.len() &&
string.len() >= prefix.len() &&
string.as_bytes()[0..prefix.len()].eq_ignore_ascii_case(prefix.as_bytes())
}