mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-22 20:47:48 +00:00
Simplify str::to_managed
This commit is contained in:
parent
a7ecde3323
commit
ac50046a11
@ -2262,9 +2262,8 @@ impl &str: StrSlice {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pure fn to_managed() -> @str {
|
pure fn to_managed() -> @str {
|
||||||
let v = at_vec::from_fn(self.len() + 1, |i| {
|
let bytes = as_bytes_slice(self);
|
||||||
if i == self.len() { 0 } else { self[i] }
|
let v = at_vec::from_fn(bytes.len(), |i| bytes[i]);
|
||||||
});
|
|
||||||
unsafe { ::cast::transmute(v) }
|
unsafe { ::cast::transmute(v) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user