Skip to content

Commit 2f9c011

Browse files
committed
Add a to_bytes iface and a handful of impls
1 parent abee158 commit 2f9c011

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/libcore/to_bytes.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
iface to_bytes {
2+
fn to_bytes() -> ~[u8];
3+
}
4+
5+
impl of to_bytes for ~[u8] {
6+
fn to_bytes() -> ~[u8] { copy self }
7+
}
8+
9+
impl of to_bytes for @~[u8] {
10+
fn to_bytes() -> ~[u8] { copy *self }
11+
}
12+
13+
impl of to_bytes for str {
14+
fn to_bytes() -> ~[u8] { str::bytes(self) }
15+
}
16+
17+
impl of to_bytes for @str {
18+
fn to_bytes() -> ~[u8] { str::bytes(*self) }
19+
}

0 commit comments

Comments
 (0)