int audit - libcore::fmt

This commit is contained in:
Nick Cameron
2015-02-23 16:07:38 +13:00
parent dcc6ce2c77
commit 67b03fbc3d
7 changed files with 73 additions and 51 deletions

View File

@@ -24,7 +24,6 @@
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(int_uint)]
#![feature(staged_api)]
#![feature(unicode)]
@@ -65,7 +64,7 @@ pub struct FormatSpec<'a> {
/// Optionally specified alignment
pub align: Alignment,
/// Packed version of various flags provided
pub flags: uint,
pub flags: u32,
/// The integer precision to use
pub precision: Count<'a>,
/// The string width requested for the resulting format
@@ -82,7 +81,7 @@ pub enum Position<'a> {
/// The argument will be in the next position. This is the default.
ArgumentNext,
/// The argument is located at a specific index.
ArgumentIs(uint),
ArgumentIs(usize),
/// The argument has a name.
ArgumentNamed(&'a str),
}
@@ -121,11 +120,11 @@ pub enum Flag {
#[derive(Copy, PartialEq)]
pub enum Count<'a> {
/// The count is specified explicitly.
CountIs(uint),
CountIs(usize),
/// The count is specified by the argument with the given name.
CountIsName(&'a str),
/// The count is specified by the argument at the given index.
CountIsParam(uint),
CountIsParam(usize),
/// The count is specified by the next parameter.
CountIsNextParam,
/// The count is implied and cannot be explicitly specified.
@@ -237,7 +236,7 @@ impl<'a> Parser<'a> {
/// Parses all of a string which is to be considered a "raw literal" in a
/// format string. This is everything outside of the braces.
fn string(&mut self, start: uint) -> &'a str {
fn string(&mut self, start: usize) -> &'a str {
loop {
// we may not consume the character, so clone the iterator
match self.cur.clone().next() {
@@ -314,13 +313,13 @@ impl<'a> Parser<'a> {
}
// Sign flags
if self.consume('+') {
spec.flags |= 1 << (FlagSignPlus as uint);
spec.flags |= 1 << (FlagSignPlus as u32);
} else if self.consume('-') {
spec.flags |= 1 << (FlagSignMinus as uint);
spec.flags |= 1 << (FlagSignMinus as u32);
}
// Alternate marker
if self.consume('#') {
spec.flags |= 1 << (FlagAlternate as uint);
spec.flags |= 1 << (FlagAlternate as u32);
}
// Width and precision
let mut havewidth = false;
@@ -333,7 +332,7 @@ impl<'a> Parser<'a> {
spec.width = CountIsParam(0);
havewidth = true;
} else {
spec.flags |= 1 << (FlagSignAwareZeroPad as uint);
spec.flags |= 1 << (FlagSignAwareZeroPad as u32);
}
}
if !havewidth {
@@ -413,7 +412,7 @@ impl<'a> Parser<'a> {
/// Optionally parses an integer at the current position. This doesn't deal
/// with overflow at all, it's just accumulating digits.
fn integer(&mut self) -> Option<uint> {
fn integer(&mut self) -> Option<usize> {
let mut cur = 0;
let mut found = false;
loop {
@@ -617,7 +616,7 @@ mod tests {
format: FormatSpec {
fill: None,
align: AlignUnknown,
flags: (1 << FlagSignMinus as uint),
flags: (1 << FlagSignMinus as u32),
precision: CountImplied,
width: CountImplied,
ty: "",
@@ -628,7 +627,7 @@ mod tests {
format: FormatSpec {
fill: None,
align: AlignUnknown,
flags: (1 << FlagSignPlus as uint) | (1 << FlagAlternate as uint),
flags: (1 << FlagSignPlus as u32) | (1 << FlagAlternate as u32),
precision: CountImplied,
width: CountImplied,
ty: "",