Use map_or instead of match

This commit is contained in:
Jeremy Stucki 2019-06-21 09:04:54 +02:00
parent 5ff2bb4dcf
commit c5c64d48b7
No known key found for this signature in database
GPG key ID: EEFCA93148042655

View file

@ -8,9 +8,9 @@ impl _StrExt for str {
if index == self.len() {
return true;
}
match self.as_bytes().get(index) {
None => false,
Some(&b) => b < 128 || b >= 192,
}
self.as_bytes()
.get(index)
.map_or(false, |&b| b < 128 || b >= 192)
}
}