Skip to content

Commit

Permalink
Simplify str::to_managed
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Oct 18, 2012
1 parent a7ecde3 commit ac50046
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/libcore/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2262,9 +2262,8 @@ impl &str: StrSlice {

#[inline]
pure fn to_managed() -> @str {
let v = at_vec::from_fn(self.len() + 1, |i| {
if i == self.len() { 0 } else { self[i] }
});
let bytes = as_bytes_slice(self);
let v = at_vec::from_fn(bytes.len(), |i| bytes[i]);
unsafe { ::cast::transmute(v) }
}

Expand Down

0 comments on commit ac50046

Please sign in to comment.