Skip to content

Commit

Permalink
Added missing assert, did some formating
Browse files Browse the repository at this point in the history
  • Loading branch information
Kimundi committed Apr 22, 2013
1 parent 582a05f commit bf4f088
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/libcore/str/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}

Expand All @@ -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))}
}
Expand Down Expand Up @@ -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());
Expand All @@ -142,14 +139,14 @@ impl OwnedAsciiCast for ~[u8] {
#[inline(always)]
fn to_ascii_consume(self) -> ~[Ascii] {
assert!(self.is_ascii());

unsafe {cast::transmute(self)}
}
}

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);
Expand Down Expand Up @@ -269,11 +266,3 @@ mod tests {
#[test] #[should_fail]
fn test_ascii_fail_char_slice() { 'λ'.to_ascii(); }
}








0 comments on commit bf4f088

Please sign in to comment.