Skip to content

Commit 9d5fa7a

Browse files
committed
auto merge of #17947 : lukemetz/rust/master, r=aturon
AsciiStr::to_lower is now AsciiStr::to_lowercase and AsciiStr::to_upper is AsciiStr::to_uppercase to match Ascii trait. Part of issue #17790. This is my first pull request so let me know if anything is incorrect. Thanks! [breaking-changes]
2 parents 8b97973 + 0ad6f0a commit 9d5fa7a

File tree

5 files changed

+39
-19
lines changed

5 files changed

+39
-19
lines changed

src/compiletest/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn load_errors(re: &Regex, testfile: &Path) -> Vec<ExpectedError> {
3131
fn parse_expected(line_num: uint, line: &str, re: &Regex) -> Option<ExpectedError> {
3232
re.captures(line).and_then(|caps| {
3333
let adjusts = caps.name("adjusts").len();
34-
let kind = caps.name("kind").to_ascii().to_lower().into_string();
34+
let kind = caps.name("kind").to_ascii().to_lowercase().into_string();
3535
let msg = caps.name("msg").trim().to_string();
3636

3737
debug!("line={} kind={} msg={}", line_num, kind, msg);

src/librustdoc/html/markdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
228228
// Transform the contents of the header into a hyphenated string
229229
let id = s.as_slice().words().map(|s| {
230230
match s.to_ascii_opt() {
231-
Some(s) => s.to_lower().into_string(),
231+
Some(s) => s.to_lowercase().into_string(),
232232
None => s.to_string()
233233
}
234234
}).collect::<Vec<String>>().connect("-");

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]

src/libterm/terminfo/parm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
530530
FormatHEX => {
531531
s = s.as_slice()
532532
.to_ascii()
533-
.to_upper()
533+
.to_uppercase()
534534
.into_bytes()
535535
.into_iter()
536536
.collect();

src/test/bench/shootout-k-nucleotide-pipes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn sort_and_fmt(mm: &HashMap<Vec<u8> , uint>, total: uint) -> String {
6565
buffer.push_str(format!("{} {:0.3f}\n",
6666
k.as_slice()
6767
.to_ascii()
68-
.to_upper()
68+
.to_uppercase()
6969
.into_string(), v).as_slice());
7070
}
7171

@@ -74,7 +74,7 @@ fn sort_and_fmt(mm: &HashMap<Vec<u8> , uint>, total: uint) -> String {
7474

7575
// given a map, search for the frequency of a pattern
7676
fn find(mm: &HashMap<Vec<u8> , uint>, key: String) -> uint {
77-
let key = key.into_ascii().as_slice().to_lower().into_string();
77+
let key = key.into_ascii().as_slice().to_lowercase().into_string();
7878
match mm.find_equiv(&key.as_bytes()) {
7979
option::None => { return 0u; }
8080
option::Some(&num) => { return num; }

0 commit comments

Comments
 (0)