about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarvin Löbel <loebel.marvin@gmail.com>2013-04-22 22:05:39 +0200
committerMarvin Löbel <loebel.marvin@gmail.com>2013-04-22 22:05:39 +0200
commitbf4f088eaccfe24d4c30e7bf52e4c2bd20b9ff47 (patch)
treec6fbebdd2e60e7f8ce43036a5be1752c078377bb
parent582a05fc95c8adf6ecf6318ea09ed6cd5bbe5b33 (diff)
downloadrust-bf4f088eaccfe24d4c30e7bf52e4c2bd20b9ff47.tar.gz
rust-bf4f088eaccfe24d4c30e7bf52e4c2bd20b9ff47.zip
Added missing assert, did some formating
-rw-r--r--src/libcore/str/ascii.rs13
1 files changed, 1 insertions, 12 deletions
diff --git a/src/libcore/str/ascii.rs b/src/libcore/str/ascii.rs
index 447ca3497e8..339274ab47e 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 @@ impl AsciiCast<Ascii> for u8 {
 }
 
 impl AsciiCast<Ascii> 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 @@ impl OwnedAsciiCast for ~[u8] {
 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 @@ mod tests {
     #[test] #[should_fail]
     fn test_ascii_fail_char_slice() { 'λ'.to_ascii(); }
 }
-
-
-
-
-
-
-
-