Skip to content

Commit 6304a27

Browse files
committed
auto merge of #14401 : aochagavia/rust/pr4, r=alexcrichton
Some functions implemented for the Ascii struct have the same functionality as other functions implemented for the normal chars. For consistency, I think they should have the same name, so I renamed the functions in Ascii to match the names in the Char trait. * Renamed `to_lower` to `to_lowercase` * Renamed `to_upper` to `to_uppercase` * Renamed `is_alpha` to `is_alphabetic` * Renamed `is_alnum` to `is_alphanumeric` * Renamed `is_lower` to `is_lowercase` * Renamed `is_upper` to `is_uppercase` [breaking-change]
2 parents 43f942f + e998958 commit 6304a27

File tree

3 files changed

+54
-12
lines changed

3 files changed

+54
-12
lines changed

src/compiletest/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
819819
let i = s.chars();
820820
let c : Vec<char> = i.map( |c| {
821821
if c.is_ascii() {
822-
c.to_ascii().to_lower().to_char()
822+
c.to_ascii().to_lowercase().to_char()
823823
} else {
824824
c
825825
}

src/libglob/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -553,18 +553,18 @@ fn in_char_specifiers(specifiers: &[CharSpecifier], c: char, options: MatchOptio
553553
// FIXME: work with non-ascii chars properly (issue #1347)
554554
if !options.case_sensitive && c.is_ascii() && start.is_ascii() && end.is_ascii() {
555555

556-
let start = start.to_ascii().to_lower();
557-
let end = end.to_ascii().to_lower();
556+
let start = start.to_ascii().to_lowercase();
557+
let end = end.to_ascii().to_lowercase();
558558

559-
let start_up = start.to_upper();
560-
let end_up = end.to_upper();
559+
let start_up = start.to_uppercase();
560+
let end_up = end.to_uppercase();
561561

562562
// only allow case insensitive matching when
563563
// both start and end are within a-z or A-Z
564564
if start != start_up && end != end_up {
565565
let start = start.to_char();
566566
let end = end.to_char();
567-
let c = c.to_ascii().to_lower().to_char();
567+
let c = c.to_ascii().to_lowercase().to_char();
568568
if c >= start && c <= end {
569569
return true;
570570
}

src/libstd/ascii.rs

+48-6
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,29 @@ impl Ascii {
3939
self.chr as char
4040
}
4141

42-
/// Convert to lowercase.
4342
#[inline]
43+
#[allow(missing_doc)]
44+
#[deprecated="renamed to `to_lowercase`"]
4445
pub fn to_lower(self) -> Ascii {
46+
self.to_lowercase()
47+
}
48+
49+
/// Convert to lowercase.
50+
#[inline]
51+
pub fn to_lowercase(self) -> Ascii {
4552
Ascii{chr: ASCII_LOWER_MAP[self.chr as uint]}
4653
}
4754

48-
/// Convert to uppercase.
4955
#[inline]
56+
#[allow(missing_doc)]
57+
#[deprecated="renamed to `to_uppercase`"]
5058
pub fn to_upper(self) -> Ascii {
59+
self.to_uppercase()
60+
}
61+
62+
/// Convert to uppercase.
63+
#[inline]
64+
pub fn to_uppercase(self) -> Ascii {
5165
Ascii{chr: ASCII_UPPER_MAP[self.chr as uint]}
5266
}
5367

@@ -59,9 +73,16 @@ impl Ascii {
5973

6074
// the following methods are like ctype, and the implementation is inspired by musl
6175

62-
/// Check if the character is a letter (a-z, A-Z)
6376
#[inline]
77+
#[allow(missing_doc)]
78+
#[deprecated="renamed to `is_alphabetic`"]
6479
pub fn is_alpha(&self) -> bool {
80+
self.is_alphabetic()
81+
}
82+
83+
/// Check if the character is a letter (a-z, A-Z)
84+
#[inline]
85+
pub fn is_alphabetic(&self) -> bool {
6586
(self.chr >= 0x41 && self.chr <= 0x5A) || (self.chr >= 0x61 && self.chr <= 0x7A)
6687
}
6788

@@ -71,9 +92,16 @@ impl Ascii {
7192
self.chr >= 0x30 && self.chr <= 0x39
7293
}
7394

74-
/// Check if the character is a letter or number
7595
#[inline]
96+
#[allow(missing_doc)]
97+
#[deprecated="renamed to `is_alphanumeric`"]
7698
pub fn is_alnum(&self) -> bool {
99+
self.is_alphanumeric()
100+
}
101+
102+
/// Check if the character is a letter or number
103+
#[inline]
104+
pub fn is_alphanumeric(&self) -> bool {
77105
self.is_alpha() || self.is_digit()
78106
}
79107

@@ -101,15 +129,29 @@ impl Ascii {
101129
(self.chr - 0x20) < 0x5F
102130
}
103131

104-
/// Checks if the character is lowercase
105132
#[inline]
133+
#[allow(missing_doc)]
134+
#[deprecated="renamed to `is_lowercase`"]
106135
pub fn is_lower(&self) -> bool {
136+
self.is_lowercase()
137+
}
138+
139+
/// Checks if the character is lowercase
140+
#[inline]
141+
pub fn is_lowercase(&self) -> bool {
107142
(self.chr - 'a' as u8) < 26
108143
}
109144

110-
/// Checks if the character is uppercase
111145
#[inline]
146+
#[allow(missing_doc)]
147+
#[deprecated="renamed to `is_uppercase`"]
112148
pub fn is_upper(&self) -> bool {
149+
self.is_uppercase()
150+
}
151+
152+
/// Checks if the character is uppercase
153+
#[inline]
154+
pub fn is_uppercase(&self) -> bool {
113155
(self.chr - 'A' as u8) < 26
114156
}
115157

0 commit comments

Comments
 (0)