Skip to content

Commit 6859a6d

Browse files
committed
auto merge of #5391 : brson/rust/to-bytes, r=graydon
r? I want to use this function as a method. There's probably a better way to design this but the existing `ToBytes` trait is not what I am looking for (it has a parameter to indicate the byte order).
2 parents e75a843 + 38ac809 commit 6859a6d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/libcore/str.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,7 @@ pub trait StrSlice {
22732273
pure fn to_owned(&self) -> ~str;
22742274
pure fn to_managed(&self) -> @str;
22752275
pure fn char_at(&self, i: uint) -> char;
2276+
fn to_bytes(&self) -> ~[u8];
22762277
}
22772278
22782279
/// Extension methods for strings
@@ -2416,6 +2417,8 @@ impl StrSlice for &self/str {
24162417
24172418
#[inline]
24182419
pure fn char_at(&self, i: uint) -> char { char_at(*self, i) }
2420+
2421+
fn to_bytes(&self) -> ~[u8] { to_bytes(*self) }
24192422
}
24202423
24212424
pub trait OwnedStr {

0 commit comments

Comments
 (0)