1
Fork 0

std: Remove i18n/l10n from format!

* The select/plural methods from format strings are removed
* The # character no longer needs to be escaped
* The \-based escapes have been removed
* '{{' is now an escape for '{'
* '}}' is now an escape for '}'

Closes #14810
[breaking-change]
This commit is contained in:
Alex Crichton 2014-05-28 09:24:28 -07:00
parent f9260d41d6
commit cac7a2053a
57 changed files with 736 additions and 1087 deletions

View file

@ -430,6 +430,7 @@ impl<'a> ::Encoder<io::IoError> for Encoder<'a> {
_name: &str,
f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { f(self) }
#[cfg(stage0)]
fn emit_enum_variant(&mut self,
name: &str,
_id: uint,
@ -448,6 +449,25 @@ impl<'a> ::Encoder<io::IoError> for Encoder<'a> {
write!(self.wr, "]\\}")
}
}
#[cfg(not(stage0))]
fn emit_enum_variant(&mut self,
name: &str,
_id: uint,
cnt: uint,
f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
// enums are encoded as strings or objects
// Bunny => "Bunny"
// Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]}
if cnt == 0 {
write!(self.wr, "{}", escape_str(name))
} else {
try!(write!(self.wr, "{{\"variant\":"));
try!(write!(self.wr, "{}", escape_str(name)));
try!(write!(self.wr, ",\"fields\":["));
try!(f(self));
write!(self.wr, "]}}")
}
}
fn emit_enum_variant_arg(&mut self,
idx: uint,
@ -473,6 +493,7 @@ impl<'a> ::Encoder<io::IoError> for Encoder<'a> {
self.emit_enum_variant_arg(idx, f)
}
#[cfg(stage0)]
fn emit_struct(&mut self,
_: &str,
_: uint,
@ -481,6 +502,15 @@ impl<'a> ::Encoder<io::IoError> for Encoder<'a> {
try!(f(self));
write!(self.wr, r"\}")
}
#[cfg(not(stage0))]
fn emit_struct(&mut self,
_: &str,
_: uint,
f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
try!(write!(self.wr, "{{"));
try!(f(self));
write!(self.wr, "}}")
}
fn emit_struct_field(&mut self,
name: &str,
@ -533,11 +563,18 @@ impl<'a> ::Encoder<io::IoError> for Encoder<'a> {
f(self)
}
#[cfg(stage0)]
fn emit_map(&mut self, _len: uint, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
try!(write!(self.wr, r"\{"));
try!(f(self));
write!(self.wr, r"\}")
}
#[cfg(not(stage0))]
fn emit_map(&mut self, _len: uint, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
try!(write!(self.wr, "{{"));
try!(f(self));
write!(self.wr, "}}")
}
fn emit_map_elt_key(&mut self,
idx: uint,
@ -670,6 +707,7 @@ impl<'a> ::Encoder<io::IoError> for PrettyEncoder<'a> {
}
#[cfg(stage0)]
fn emit_struct(&mut self,
_: &str,
len: uint,
@ -684,6 +722,21 @@ impl<'a> ::Encoder<io::IoError> for PrettyEncoder<'a> {
write!(self.wr, "\n{}\\}", spaces(self.indent))
}
}
#[cfg(not(stage0))]
fn emit_struct(&mut self,
_: &str,
len: uint,
f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
if len == 0 {
write!(self.wr, "{{}}")
} else {
try!(write!(self.wr, "{{"));
self.indent += 2;
try!(f(self));
self.indent -= 2;
write!(self.wr, "\n{}}}", spaces(self.indent))
}
}
fn emit_struct_field(&mut self,
name: &str,
@ -755,6 +808,7 @@ impl<'a> ::Encoder<io::IoError> for PrettyEncoder<'a> {
f(self)
}
#[cfg(stage0)]
fn emit_map(&mut self,
len: uint,
f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
@ -768,6 +822,20 @@ impl<'a> ::Encoder<io::IoError> for PrettyEncoder<'a> {
write!(self.wr, "\n{}\\}", spaces(self.indent))
}
}
#[cfg(not(stage0))]
fn emit_map(&mut self,
len: uint,
f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
if len == 0 {
write!(self.wr, "{{}}")
} else {
try!(write!(self.wr, "{{"));
self.indent += 2;
try!(f(self));
self.indent -= 2;
write!(self.wr, "\n{}}}", spaces(self.indent))
}
}
fn emit_map_elt_key(&mut self,
idx: uint,