rust/src/libcore/to_bytes.rs

20 lines
328 B
Rust
Raw Normal View History

trait ToBytes {
fn to_bytes() -> ~[u8];
}
impl ~[u8]: ToBytes {
fn to_bytes() -> ~[u8] { copy self }
}
impl @~[u8]: ToBytes {
fn to_bytes() -> ~[u8] { copy *self }
}
impl ~str: ToBytes {
fn to_bytes() -> ~[u8] { str::bytes(self) }
}
impl @(~str): ToBytes {
fn to_bytes() -> ~[u8] { str::bytes(*self) }
}