Skip to content

Commit 7f87dd1

Browse files
committed
Some small readability improvements
1 parent 90b957a commit 7f87dd1

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

src/libcore/char/methods.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,7 @@ impl char {
553553
pub fn is_alphabetic(self) -> bool {
554554
match self {
555555
'a'..='z' | 'A'..='Z' => true,
556-
c if c > '\x7f' => derived_property::Alphabetic(c),
557-
_ => false,
556+
c => c > '\x7f' && derived_property::Alphabetic(c),
558557
}
559558
}
560559

@@ -585,8 +584,7 @@ impl char {
585584
pub fn is_lowercase(self) -> bool {
586585
match self {
587586
'a'..='z' => true,
588-
c if c > '\x7f' => derived_property::Lowercase(c),
589-
_ => false,
587+
c => c > '\x7f' && derived_property::Lowercase(c),
590588
}
591589
}
592590

@@ -617,8 +615,7 @@ impl char {
617615
pub fn is_uppercase(self) -> bool {
618616
match self {
619617
'A'..='Z' => true,
620-
c if c > '\x7f' => derived_property::Uppercase(c),
621-
_ => false,
618+
c => c > '\x7f' && derived_property::Uppercase(c),
622619
}
623620
}
624621

@@ -646,8 +643,7 @@ impl char {
646643
pub fn is_whitespace(self) -> bool {
647644
match self {
648645
' ' | '\x09'..='\x0d' => true,
649-
c if c > '\x7f' => property::White_Space(c),
650-
_ => false,
646+
c => c > '\x7f' && property::White_Space(c),
651647
}
652648
}
653649

@@ -744,8 +740,7 @@ impl char {
744740
pub fn is_numeric(self) -> bool {
745741
match self {
746742
'0'..='9' => true,
747-
c if c > '\x7f' => general_category::N(c),
748-
_ => false,
743+
c => c > '\x7f' && general_category::N(c),
749744
}
750745
}
751746

src/libcore/str/pattern.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,7 @@ unsafe impl<'a> Searcher<'a> for CharSearcher<'a> {
296296
fn next_match(&mut self) -> Option<(usize, usize)> {
297297
loop {
298298
// get the haystack after the last character found
299-
let bytes = if let Some(slice) = self.haystack.as_bytes()
300-
.get(self.finger..self.finger_back) {
301-
slice
302-
} else {
303-
return None;
304-
};
299+
let bytes = self.haystack.as_bytes().get(self.finger..self.finger_back)?;
305300
// the last byte of the utf8 encoded needle
306301
let last_byte = unsafe { *self.utf8_encoded.get_unchecked(self.utf8_size - 1) };
307302
if let Some(index) = memchr::memchr(last_byte, bytes) {

0 commit comments

Comments
 (0)