Register new snapshots
This commit is contained in:
parent
023dfb0c89
commit
262c1efe63
20 changed files with 11 additions and 756 deletions
|
|
@ -325,18 +325,9 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
|
|||
|
||||
let mut filler = Filler { buf: &mut buf, end: &mut end };
|
||||
match sign {
|
||||
// NOTE(stage0): Remove cfg after a snapshot
|
||||
#[cfg(not(stage0))]
|
||||
SignNeg => {
|
||||
let _ = fmt::write(&mut filler, format_args!("{:-}", exp));
|
||||
}
|
||||
// NOTE(stage0): Remove match arm after a snapshot
|
||||
#[cfg(stage0)]
|
||||
SignNeg => {
|
||||
let _ = format_args!(|args| {
|
||||
fmt::write(&mut filler, args)
|
||||
}, "{:-}", exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,21 +70,11 @@ pub trait FormatWriter {
|
|||
/// This function will return an instance of `FormatError` on error.
|
||||
fn write(&mut self, bytes: &[u8]) -> Result;
|
||||
|
||||
// NOTE(stage0): Remove cfg after a snapshot
|
||||
#[cfg(not(stage0))]
|
||||
/// Glue for usage of the `write!` macro with implementers of this trait.
|
||||
///
|
||||
/// This method should generally not be invoked manually, but rather through
|
||||
/// the `write!` macro itself.
|
||||
fn write_fmt(&mut self, args: Arguments) -> Result { write(self, args) }
|
||||
|
||||
// NOTE(stage0): Remove method after a snapshot
|
||||
#[cfg(stage0)]
|
||||
/// Glue for usage of the `write!` macro with implementers of this trait.
|
||||
///
|
||||
/// This method should generally not be invoked manually, but rather through
|
||||
/// the `write!` macro itself.
|
||||
fn write_fmt(&mut self, args: &Arguments) -> Result { write(self, args) }
|
||||
}
|
||||
|
||||
/// A struct to represent both where to emit formatting strings to and how they
|
||||
|
|
@ -204,17 +194,9 @@ pub struct Arguments<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Show for Arguments<'a> {
|
||||
// NOTE(stage0): Remove cfg after a snapshot
|
||||
#[cfg(not(stage0))]
|
||||
fn fmt(&self, fmt: &mut Formatter) -> Result {
|
||||
write(fmt.buf, *self)
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove method after a snapshot
|
||||
#[cfg(stage0)]
|
||||
fn fmt(&self, fmt: &mut Formatter) -> Result {
|
||||
write(fmt.buf, self)
|
||||
}
|
||||
}
|
||||
|
||||
/// When a format is not otherwise specified, types are formatted by ascribing
|
||||
|
|
@ -287,8 +269,6 @@ static DEFAULT_ARGUMENT: rt::Argument<'static> = rt::Argument {
|
|||
}
|
||||
};
|
||||
|
||||
// NOTE(stage0): Remove cfg after a snapshot
|
||||
#[cfg(not(stage0))]
|
||||
/// The `write` function takes an output stream, a precompiled format string,
|
||||
/// and a list of arguments. The arguments will be formatted according to the
|
||||
/// specified format string into the output stream provided.
|
||||
|
|
@ -342,61 +322,6 @@ pub fn write(output: &mut FormatWriter, args: Arguments) -> Result {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove function after a snapshot
|
||||
#[cfg(stage0)]
|
||||
/// The `write` function takes an output stream, a precompiled format string,
|
||||
/// and a list of arguments. The arguments will be formatted according to the
|
||||
/// specified format string into the output stream provided.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * output - the buffer to write output to
|
||||
/// * args - the precompiled arguments generated by `format_args!`
|
||||
#[experimental = "libcore and I/O have yet to be reconciled, and this is an \
|
||||
implementation detail which should not otherwise be exported"]
|
||||
pub fn write(output: &mut FormatWriter, args: &Arguments) -> Result {
|
||||
let mut formatter = Formatter {
|
||||
flags: 0,
|
||||
width: None,
|
||||
precision: None,
|
||||
buf: output,
|
||||
align: rt::AlignUnknown,
|
||||
fill: ' ',
|
||||
args: args.args,
|
||||
curarg: args.args.iter(),
|
||||
};
|
||||
|
||||
let mut pieces = args.pieces.iter();
|
||||
|
||||
match args.fmt {
|
||||
None => {
|
||||
// We can use default formatting parameters for all arguments.
|
||||
for _ in range(0, args.args.len()) {
|
||||
try!(formatter.buf.write(pieces.next().unwrap().as_bytes()));
|
||||
try!(formatter.run(&DEFAULT_ARGUMENT));
|
||||
}
|
||||
}
|
||||
Some(fmt) => {
|
||||
// Every spec has a corresponding argument that is preceded by
|
||||
// a string piece.
|
||||
for (arg, piece) in fmt.iter().zip(pieces.by_ref()) {
|
||||
try!(formatter.buf.write(piece.as_bytes()));
|
||||
try!(formatter.run(arg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// There can be only one trailing string piece left.
|
||||
match pieces.next() {
|
||||
Some(piece) => {
|
||||
try!(formatter.buf.write(piece.as_bytes()));
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl<'a> Formatter<'a> {
|
||||
|
||||
// First up is the collection of functions used to execute a format string
|
||||
|
|
@ -603,22 +528,12 @@ impl<'a> Formatter<'a> {
|
|||
self.buf.write(data)
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove cfg after a snapshot
|
||||
#[cfg(not(stage0))]
|
||||
/// Writes some formatted information into this instance
|
||||
#[unstable = "reconciling core and I/O may alter this definition"]
|
||||
pub fn write_fmt(&mut self, fmt: Arguments) -> Result {
|
||||
write(self.buf, fmt)
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove method after a snapshot
|
||||
#[cfg(stage0)]
|
||||
/// Writes some formatted information into this instance
|
||||
#[unstable = "reconciling core and I/O may alter this definition"]
|
||||
pub fn write_fmt(&mut self, fmt: &Arguments) -> Result {
|
||||
write(self.buf, fmt)
|
||||
}
|
||||
|
||||
/// Flags for formatting (packed version of rt::Flag)
|
||||
#[experimental = "return type may change and method was just created"]
|
||||
pub fn flags(&self) -> uint { self.flags }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue