Skip to content

Commit e13cb3d

Browse files
=SimonSapin
=
authored andcommitted
Renamed AsciiStr::to_lower and AsciiStr::to_upper
Now AsciiStr::to_lowercase and AsciiStr::to_uppercase to match Ascii trait. [breaking-change]
1 parent fa6959f commit e13cb3d

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

src/libstd/ascii.rs

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ impl Ascii {
6262
Ascii{chr: ASCII_LOWER_MAP[self.chr as uint]}
6363
}
6464

65+
/// Deprecated: use `to_uppercase`
6566
#[inline]
66-
#[allow(missing_doc)]
6767
#[deprecated="renamed to `to_uppercase`"]
6868
pub fn to_upper(self) -> Ascii {
6969
self.to_uppercase()
@@ -139,8 +139,8 @@ impl Ascii {
139139
(self.chr - 0x20) < 0x5F
140140
}
141141

142+
/// Deprecated: use `to_lowercase`
142143
#[inline]
143-
#[allow(missing_doc)]
144144
#[deprecated="renamed to `is_lowercase`"]
145145
pub fn is_lower(&self) -> bool {
146146
self.is_lowercase()
@@ -319,12 +319,20 @@ pub trait AsciiStr {
319319
/// Convert to a string.
320320
fn as_str_ascii<'a>(&'a self) -> &'a str;
321321

322-
/// Convert to vector representing a lower cased ascii string.
322+
/// Deprecated: use `to_lowercase`
323+
#[deprecated="renamed `to_lowercase`"]
323324
fn to_lower(&self) -> Vec<Ascii>;
324325

325-
/// Convert to vector representing a upper cased ascii string.
326+
/// Convert to vector representing a lower cased ascii string.
327+
fn to_lowercase(&self) -> Vec<Ascii>;
328+
329+
/// Deprecated: use `to_uppercase`
330+
#[deprecated="renamed `to_uppercase`"]
326331
fn to_upper(&self) -> Vec<Ascii>;
327332

333+
/// Convert to vector representing a upper cased ascii string.
334+
fn to_uppercase(&self) -> Vec<Ascii>;
335+
328336
/// Compares two Ascii strings ignoring case.
329337
fn eq_ignore_case(self, other: &[Ascii]) -> bool;
330338
}
@@ -337,11 +345,21 @@ impl<'a> AsciiStr for &'a [Ascii] {
337345

338346
#[inline]
339347
fn to_lower(&self) -> Vec<Ascii> {
348+
self.to_lowercase()
349+
}
350+
351+
#[inline]
352+
fn to_lowercase(&self) -> Vec<Ascii> {
340353
self.iter().map(|a| a.to_lowercase()).collect()
341354
}
342355

343356
#[inline]
344357
fn to_upper(&self) -> Vec<Ascii> {
358+
self.to_uppercase()
359+
}
360+
361+
#[inline]
362+
fn to_uppercase(&self) -> Vec<Ascii> {
345363
self.iter().map(|a| a.to_uppercase()).collect()
346364
}
347365

@@ -615,12 +633,13 @@ mod tests {
615633
assert_eq!(v.as_slice().to_ascii(), b);
616634
assert_eq!("( ;".to_string().as_slice().to_ascii(), b);
617635

618-
assert_eq!("abCDef&?#".to_ascii().to_lower().into_string(), "abcdef&?#".to_string());
619-
assert_eq!("abCDef&?#".to_ascii().to_upper().into_string(), "ABCDEF&?#".to_string());
636+
assert_eq!("abCDef&?#".to_ascii().to_lowercase().into_string(), "abcdef&?#".to_string());
637+
assert_eq!("abCDef&?#".to_ascii().to_uppercase().into_string(), "ABCDEF&?#".to_string());
620638

621-
assert_eq!("".to_ascii().to_lower().into_string(), "".to_string());
622-
assert_eq!("YMCA".to_ascii().to_lower().into_string(), "ymca".to_string());
623-
assert_eq!("abcDEFxyz:.;".to_ascii().to_upper().into_string(), "ABCDEFXYZ:.;".to_string());
639+
assert_eq!("".to_ascii().to_lowercase().into_string(), "".to_string());
640+
assert_eq!("YMCA".to_ascii().to_lowercase().into_string(), "ymca".to_string());
641+
let mixed = "abcDEFxyz:.;".to_ascii();
642+
assert_eq!(mixed.to_uppercase().into_string(), "ABCDEFXYZ:.;".to_string());
624643

625644
assert!("aBcDeF&?#".to_ascii().eq_ignore_case("AbCdEf&?#".to_ascii()));
626645

@@ -632,11 +651,12 @@ mod tests {
632651

633652
#[test]
634653
fn test_ascii_vec_ng() {
635-
assert_eq!("abCDef&?#".to_ascii().to_lower().into_string(), "abcdef&?#".to_string());
636-
assert_eq!("abCDef&?#".to_ascii().to_upper().into_string(), "ABCDEF&?#".to_string());
637-
assert_eq!("".to_ascii().to_lower().into_string(), "".to_string());
638-
assert_eq!("YMCA".to_ascii().to_lower().into_string(), "ymca".to_string());
639-
assert_eq!("abcDEFxyz:.;".to_ascii().to_upper().into_string(), "ABCDEFXYZ:.;".to_string());
654+
assert_eq!("abCDef&?#".to_ascii().to_lowercase().into_string(), "abcdef&?#".to_string());
655+
assert_eq!("abCDef&?#".to_ascii().to_uppercase().into_string(), "ABCDEF&?#".to_string());
656+
assert_eq!("".to_ascii().to_lowercase().into_string(), "".to_string());
657+
assert_eq!("YMCA".to_ascii().to_lowercase().into_string(), "ymca".to_string());
658+
let mixed = "abcDEFxyz:.;".to_ascii();
659+
assert_eq!(mixed.to_uppercase().into_string(), "ABCDEFXYZ:.;".to_string());
640660
}
641661

642662
#[test]

0 commit comments

Comments
 (0)