Skip to content

Commit f7ccae5

Browse files
committed
Rename functions in Ascii
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]
1 parent 6cf4301 commit f7ccae5

File tree

1 file changed

+48
-6
lines changed

1 file changed

+48
-6
lines changed

src/libstd/ascii.rs

Lines changed: 48 additions & 6 deletions
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)