rust/src/libcore/to_bytes.rs

20 lines
333 B
Rust
Raw Normal View History

trait to_bytes {
fn to_bytes() -> ~[u8];
}
2012-08-07 20:10:06 -05:00
impl ~[u8]: to_bytes {
fn to_bytes() -> ~[u8] { copy self }
}
2012-08-07 20:10:06 -05:00
impl @~[u8]: to_bytes {
fn to_bytes() -> ~[u8] { copy *self }
}
2012-08-07 20:10:06 -05:00
impl ~str: to_bytes {
fn to_bytes() -> ~[u8] { str::bytes(self) }
}
2012-08-07 20:10:06 -05:00
impl @(~str): to_bytes {
fn to_bytes() -> ~[u8] { str::bytes(*self) }
}