From bf4f088eaccfe24d4c30e7bf52e4c2bd20b9ff47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20L=C3=B6bel?= Date: Mon, 22 Apr 2013 22:05:39 +0200 Subject: [PATCH] Added missing assert, did some formating --- src/libcore/str/ascii.rs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/libcore/str/ascii.rs b/src/libcore/str/ascii.rs index 447ca3497e87..339274ab47e4 100644 --- a/src/libcore/str/ascii.rs +++ b/src/libcore/str/ascii.rs @@ -74,7 +74,6 @@ impl<'self> AsciiCast<&'self[Ascii]> for &'self [u8] { #[inline(always)] fn to_ascii(&self) -> &'self[Ascii] { assert!(self.is_ascii()); - unsafe{ cast::transmute(*self) } } @@ -91,7 +90,6 @@ impl<'self> AsciiCast<&'self[Ascii]> for &'self str { #[inline(always)] fn to_ascii(&self) -> &'self[Ascii] { assert!(self.is_ascii()); - let (p,len): (*u8, uint) = unsafe{ cast::transmute(*self) }; unsafe{ cast::transmute((p, len - 1))} } @@ -119,7 +117,6 @@ fn is_ascii(&self) -> bool { } impl AsciiCast for char { - #[inline(always)] fn to_ascii(&self) -> Ascii { assert!(self.is_ascii()); @@ -142,7 +139,6 @@ impl OwnedAsciiCast for ~[u8] { #[inline(always)] fn to_ascii_consume(self) -> ~[Ascii] { assert!(self.is_ascii()); - unsafe {cast::transmute(self)} } } @@ -150,6 +146,7 @@ fn to_ascii_consume(self) -> ~[Ascii] { impl OwnedAsciiCast for ~str { #[inline(always)] fn to_ascii_consume(self) -> ~[Ascii] { + assert!(self.is_ascii()); let mut s = self; unsafe { str::raw::pop_byte(&mut s); @@ -269,11 +266,3 @@ fn test_ascii_to_str_consume() { #[test] #[should_fail] fn test_ascii_fail_char_slice() { 'λ'.to_ascii(); } } - - - - - - - -