diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2012-07-03 21:30:09 -0700 |
|---|---|---|
| committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2012-07-03 21:30:09 -0700 |
| commit | 2f9c0114fa0b0d3b018b37dcfd0eafaf01d6c48a (patch) | |
| tree | 9de67e53b1647ab1d66fd37f53f0651d245a2120 /src/libcore | |
| parent | abee1589451c513bb0b77bb7001a0ea592dc67c3 (diff) | |
| download | rust-2f9c0114fa0b0d3b018b37dcfd0eafaf01d6c48a.tar.gz rust-2f9c0114fa0b0d3b018b37dcfd0eafaf01d6c48a.zip | |
Add a to_bytes iface and a handful of impls
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/to_bytes.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libcore/to_bytes.rs b/src/libcore/to_bytes.rs new file mode 100644 index 00000000000..4bfd16344cb --- /dev/null +++ b/src/libcore/to_bytes.rs @@ -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) } +} |
