Skip to content

Commit 7d86429

Browse files
committed
libcore: Add an implementation of to_str for &str.
It duplicates the string.
1 parent 09df8f1 commit 7d86429

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/libcore/to_str.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ impl (): ToStr {
4646
impl ~str: ToStr {
4747
fn to_str() -> ~str { self }
4848
}
49+
impl &str: ToStr {
50+
fn to_str() -> ~str { str::from_slice(self) }
51+
}
4952

5053
impl<A: ToStr copy, B: ToStr copy> (A, B): ToStr {
5154
fn to_str() -> ~str {

0 commit comments

Comments
 (0)