Skip to content

Commit b3f1333

Browse files
author
Thomas Bahn
committed
Fix warnings about pattern bindings
Some pattern binding were named the same as one of the variants of the type `AsciiChar`. These were intentionally not matching against `AsciiChar::*`.
1 parent c9aca47 commit b3f1333

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/ascii_str.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl AsciiStr {
197197
/// assert_eq!("white \tspace \t", example.trim_start());
198198
/// ```
199199
pub fn trim_start(&self) -> &Self {
200-
&self[self.chars().take_while(|a| a.is_whitespace()).count()..]
200+
&self[self.chars().take_while(|ch| ch.is_whitespace()).count()..]
201201
}
202202

203203
/// Returns an ASCII string slice with trailing whitespace removed.
@@ -209,7 +209,11 @@ impl AsciiStr {
209209
/// assert_eq!(" \twhite \tspace", example.trim_end());
210210
/// ```
211211
pub fn trim_end(&self) -> &Self {
212-
let trimmed = self.chars().rev().take_while(|a| a.is_whitespace()).count();
212+
let trimmed = self
213+
.chars()
214+
.rev()
215+
.take_while(|ch| ch.is_whitespace())
216+
.count();
213217
&self[..self.len() - trimmed]
214218
}
215219

@@ -219,20 +223,20 @@ impl AsciiStr {
219223
&& self
220224
.chars()
221225
.zip(other.chars())
222-
.all(|(a, b)| a.eq_ignore_ascii_case(&b))
226+
.all(|(ch, other_ch)| ch.eq_ignore_ascii_case(&other_ch))
223227
}
224228

225229
/// Replaces lowercase letters with their uppercase equivalent.
226230
pub fn make_ascii_uppercase(&mut self) {
227-
for a in self.chars_mut() {
228-
*a = a.to_ascii_uppercase();
231+
for ch in self.chars_mut() {
232+
*ch = ch.to_ascii_uppercase();
229233
}
230234
}
231235

232236
/// Replaces uppercase letters with their lowercase equivalent.
233237
pub fn make_ascii_lowercase(&mut self) {
234-
for a in self.chars_mut() {
235-
*a = a.to_ascii_lowercase();
238+
for ch in self.chars_mut() {
239+
*ch = ch.to_ascii_lowercase();
236240
}
237241
}
238242

@@ -605,7 +609,7 @@ impl<'a> Iterator for Split<'a> {
605609
if !self.ended {
606610
let start: &AsciiStr = self.chars.as_str();
607611
let split_on = self.on;
608-
if let Some(at) = self.chars.position(|c| c == split_on) {
612+
if let Some(at) = self.chars.position(|ch| ch == split_on) {
609613
Some(&start[..at])
610614
} else {
611615
self.ended = true;
@@ -621,7 +625,7 @@ impl<'a> DoubleEndedIterator for Split<'a> {
621625
if !self.ended {
622626
let start: &AsciiStr = self.chars.as_str();
623627
let split_on = self.on;
624-
if let Some(at) = self.chars.rposition(|c| c == split_on) {
628+
if let Some(at) = self.chars.rposition(|ch| ch == split_on) {
625629
Some(&start[at + 1..])
626630
} else {
627631
self.ended = true;

tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn extend_from_iterator() {
130130
.unwrap()
131131
.split(AsciiChar::Space)
132132
.map(|case| {
133-
if case.chars().all(|a| a.is_uppercase()) {
133+
if case.chars().all(|ch| ch.is_uppercase()) {
134134
Cow::from(case)
135135
} else {
136136
Cow::from(case.to_ascii_uppercase())

0 commit comments

Comments
 (0)