diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-05-09 18:45:36 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-05-12 11:28:57 -0700 |
| commit | 6559a3675e021c9e8a416fc0d9ef416ddfda2f13 (patch) | |
| tree | 9c4b58b67b27dfc286e56e2bd2f67bf38d599ead /src/libstd | |
| parent | e8053b9a7ff91b6a69238c1d7dea99be34bb7a3b (diff) | |
| download | rust-6559a3675e021c9e8a416fc0d9ef416ddfda2f13.tar.gz rust-6559a3675e021c9e8a416fc0d9ef416ddfda2f13.zip | |
librustc: Remove all uses of `~str` from librustc.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/fmt/mod.rs | 14 | ||||
| -rw-r--r-- | src/libstd/macros.rs | 8 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index b4bb6236f08..fecd68e049a 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -504,6 +504,7 @@ use slice::{Vector, ImmutableVector}; use slice; use str::{StrSlice, StrAllocating, UTF16Item, ScalarValue, LoneSurrogate}; use str; +use strbuf::StrBuf; pub use self::num::radix; pub use self::num::Radix; @@ -788,6 +789,11 @@ pub fn format(args: &Arguments) -> ~str { unsafe { format_unsafe(args.fmt, args.args) } } +/// Temporary transitionary thing. +pub fn format_strbuf(args: &Arguments) -> StrBuf { + unsafe { format_unsafe_strbuf(args.fmt, args.args) } +} + /// The unsafe version of the formatting function. /// /// This is currently an unsafe function because the types of all arguments @@ -815,6 +821,14 @@ pub unsafe fn format_unsafe(fmt: &[rt::Piece], args: &[Argument]) -> ~str { return str::from_utf8(output.unwrap().as_slice()).unwrap().to_owned(); } +/// Temporary transitionary thing. +pub unsafe fn format_unsafe_strbuf(fmt: &[rt::Piece], args: &[Argument]) + -> StrBuf { + let mut output = MemWriter::new(); + write_unsafe(&mut output as &mut io::Writer, fmt, args).unwrap(); + return str::from_utf8(output.unwrap().as_slice()).unwrap().into_strbuf(); +} + impl<'a> Formatter<'a> { // First up is the collection of functions used to execute a format string diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 1efe56756ed..3a0e78b39d1 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -229,6 +229,14 @@ macro_rules! format( ) ) +/// Temporary transitionary thing. +#[macro_export] +macro_rules! format_strbuf( + ($($arg:tt)*) => ( + format_args!(::std::fmt::format_strbuf, $($arg)*) + ) +) + /// Use the `format!` syntax to write data into a buffer of type `&mut Writer`. /// See `std::fmt` for more information. /// |
