Add a to_bytes iface and a handful of impls
This commit is contained in:
parent
abee158945
commit
2f9c0114fa
1 changed files with 19 additions and 0 deletions
19
src/libcore/to_bytes.rs
Normal file
19
src/libcore/to_bytes.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
iface to_bytes {
|
||||
fn to_bytes() -> ~[u8];
|
||||
}
|
||||
|
||||
impl of to_bytes for ~[u8] {
|
||||
fn to_bytes() -> ~[u8] { copy self }
|
||||
}
|
||||
|
||||
impl of to_bytes for @~[u8] {
|
||||
fn to_bytes() -> ~[u8] { copy *self }
|
||||
}
|
||||
|
||||
impl of to_bytes for str {
|
||||
fn to_bytes() -> ~[u8] { str::bytes(self) }
|
||||
}
|
||||
|
||||
impl of to_bytes for @str {
|
||||
fn to_bytes() -> ~[u8] { str::bytes(*self) }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue