From ee8365ad81115d79e1a33ef0c034c4a74cf01819 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 18 Jul 2014 14:16:23 +0100 Subject: [PATCH] Make std::ascii::ASCII_{UPPER,LOWER}_MAP public. --- src/libstd/ascii.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index f6138ad59b3..2b1c15efd8b 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -400,12 +400,12 @@ pub trait StrAsciiExt { impl<'a> StrAsciiExt for &'a str { #[inline] fn to_ascii_upper(&self) -> String { - unsafe { str_copy_map_bytes(*self, ASCII_UPPER_MAP) } + unsafe { str_copy_map_bytes(*self, &ASCII_UPPER_MAP) } } #[inline] fn to_ascii_lower(&self) -> String { - unsafe { str_copy_map_bytes(*self, ASCII_LOWER_MAP) } + unsafe { str_copy_map_bytes(*self, &ASCII_LOWER_MAP) } } #[inline] @@ -422,17 +422,17 @@ fn eq_ignore_ascii_case(&self, other: &str) -> bool { impl OwnedStrAsciiExt for String { #[inline] fn into_ascii_upper(self) -> String { - unsafe { str_map_bytes(self, ASCII_UPPER_MAP) } + unsafe { str_map_bytes(self, &ASCII_UPPER_MAP) } } #[inline] fn into_ascii_lower(self) -> String { - unsafe { str_map_bytes(self, ASCII_LOWER_MAP) } + unsafe { str_map_bytes(self, &ASCII_LOWER_MAP) } } } #[inline] -unsafe fn str_map_bytes(string: String, map: &'static [u8]) -> String { +unsafe fn str_map_bytes(string: String, map: &[u8, ..256]) -> String { let mut bytes = string.into_bytes(); for b in bytes.mut_iter() { @@ -443,7 +443,7 @@ unsafe fn str_map_bytes(string: String, map: &'static [u8]) -> String { } #[inline] -unsafe fn str_copy_map_bytes(string: &str, map: &'static [u8]) -> String { +unsafe fn str_copy_map_bytes(string: &str, map: &[u8, ..256]) -> String { let mut s = String::from_str(string); for b in s.as_mut_bytes().mut_iter() { *b = map[*b as uint]; @@ -451,7 +451,7 @@ unsafe fn str_copy_map_bytes(string: &str, map: &'static [u8]) -> String { s.into_string() } -static ASCII_LOWER_MAP: &'static [u8] = &[ +pub static ASCII_LOWER_MAP: [u8, ..256] = [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, @@ -490,7 +490,7 @@ unsafe fn str_copy_map_bytes(string: &str, map: &'static [u8]) -> String { 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, ]; -static ASCII_UPPER_MAP: &'static [u8] = &[ +pub static ASCII_UPPER_MAP: [u8, ..256] = [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, -- 2.44.0