diff options
| author | bors <bors@rust-lang.org> | 2013-06-11 21:37:43 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-06-11 21:37:43 -0700 |
| commit | cc80652e4a627378a36b50fab9e72349129cb56a (patch) | |
| tree | ada1e23e714b7dc587d86aeddb54a954dded8f3a /src/libstd/rt | |
| parent | 7033dfcf917ccef44fbc3e33d31814455c13b4c6 (diff) | |
| parent | 9f0c85acc967110c85f9a8bdcb32df4606a6dff5 (diff) | |
| download | rust-cc80652e4a627378a36b50fab9e72349129cb56a.tar.gz rust-cc80652e4a627378a36b50fab9e72349129cb56a.zip | |
auto merge of #7060 : huonw/rust/more-str, r=thestinger
There are now only half-a-dozen or so functions left `std::str` that should be methods. Highlights: - `.substr` was removed, since most of the uses of it in the code base were actually incorrect (it had a weird mixing of a byte index and a unicode character count), adding `.slice_chars` if one wants to handle characters, and the normal `.slice` method to handle bytes. - Code duplication between the two impls for `connect` and `concat` was removed via a new `Str` trait, that is purely designed to allow an explicit -> `&str` conversion (`.as_slice()`) - Deconfuse the 5 different functions for converting to `[u8]` (3 of which had actually incorrect documentation: implying that they didn't have the null terminator), into 3: `as_bytes` (all strings), `as_bytes_with_null` (`&'static str`, `@str` and `~str`) and `as_bytes_with_null_consume` (`~str`). None of these allocate, unlike the old versions. (cc @thestinger)
Diffstat (limited to 'src/libstd/rt')
| -rw-r--r-- | src/libstd/rt/io/file.rs | 2 | ||||
| -rw-r--r-- | src/libstd/rt/io/flate.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/rt/io/file.rs b/src/libstd/rt/io/file.rs index 1f61cf25fbd..a99f5da032c 100644 --- a/src/libstd/rt/io/file.rs +++ b/src/libstd/rt/io/file.rs @@ -75,5 +75,5 @@ fn super_simple_smoke_test_lets_go_read_some_files_and_have_a_good_time() { let message = "it's alright. have a good time"; let filename = &Path("test.txt"); let mut outstream = FileStream::open(filename, Create, Read).unwrap(); - outstream.write(message.to_bytes()); + outstream.write(message.as_bytes()); } diff --git a/src/libstd/rt/io/flate.rs b/src/libstd/rt/io/flate.rs index 0a9e0b1e38f..e57b80658ee 100644 --- a/src/libstd/rt/io/flate.rs +++ b/src/libstd/rt/io/flate.rs @@ -108,7 +108,7 @@ mod test { let mem_writer = MemWriter::new(); let mut deflate_writer = DeflateWriter::new(mem_writer); let in_msg = "test"; - let in_bytes = in_msg.to_bytes(); + let in_bytes = in_msg.as_bytes(); deflate_writer.write(in_bytes); deflate_writer.flush(); let buf = deflate_writer.inner().inner(); |
