Skip to content

Commit 8dccc0e

Browse files
committed
Merge branch 'master' of https://github.com/Zenithsiz/rust-ascii into unsafe-doc
2 parents 2041af1 + b3f1333 commit 8dccc0e

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/ascii_str.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl AsciiStr {
205205
/// assert_eq!("white \tspace \t", example.trim_start());
206206
/// ```
207207
pub fn trim_start(&self) -> &Self {
208-
&self[self.chars().take_while(|a| a.is_whitespace()).count()..]
208+
&self[self.chars().take_while(|ch| ch.is_whitespace()).count()..]
209209
}
210210

211211
/// Returns an ASCII string slice with trailing whitespace removed.
@@ -217,7 +217,11 @@ impl AsciiStr {
217217
/// assert_eq!(" \twhite \tspace", example.trim_end());
218218
/// ```
219219
pub fn trim_end(&self) -> &Self {
220-
let trimmed = self.chars().rev().take_while(|a| a.is_whitespace()).count();
220+
let trimmed = self
221+
.chars()
222+
.rev()
223+
.take_while(|ch| ch.is_whitespace())
224+
.count();
221225
&self[..self.len() - trimmed]
222226
}
223227

@@ -227,20 +231,20 @@ impl AsciiStr {
227231
&& self
228232
.chars()
229233
.zip(other.chars())
230-
.all(|(a, b)| a.eq_ignore_ascii_case(&b))
234+
.all(|(ch, other_ch)| ch.eq_ignore_ascii_case(&other_ch))
231235
}
232236

233237
/// Replaces lowercase letters with their uppercase equivalent.
234238
pub fn make_ascii_uppercase(&mut self) {
235-
for a in self.chars_mut() {
236-
*a = a.to_ascii_uppercase();
239+
for ch in self.chars_mut() {
240+
*ch = ch.to_ascii_uppercase();
237241
}
238242
}
239243

240244
/// Replaces uppercase letters with their lowercase equivalent.
241245
pub fn make_ascii_lowercase(&mut self) {
242-
for a in self.chars_mut() {
243-
*a = a.to_ascii_lowercase();
246+
for ch in self.chars_mut() {
247+
*ch = ch.to_ascii_lowercase();
244248
}
245249
}
246250

@@ -613,7 +617,7 @@ impl<'a> Iterator for Split<'a> {
613617
if !self.ended {
614618
let start: &AsciiStr = self.chars.as_str();
615619
let split_on = self.on;
616-
if let Some(at) = self.chars.position(|c| c == split_on) {
620+
if let Some(at) = self.chars.position(|ch| ch == split_on) {
617621
Some(&start[..at])
618622
} else {
619623
self.ended = true;
@@ -629,7 +633,7 @@ impl<'a> DoubleEndedIterator for Split<'a> {
629633
if !self.ended {
630634
let start: &AsciiStr = self.chars.as_str();
631635
let split_on = self.on;
632-
if let Some(at) = self.chars.rposition(|c| c == split_on) {
636+
if let Some(at) = self.chars.rposition(|ch| ch == split_on) {
633637
Some(&start[at + 1..])
634638
} else {
635639
self.ended = true;

tests.rs

Lines changed: 1 addition & 1 deletion
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)