Follow rust std: fmt::Writer is implemented by String

This commit is contained in:
Thomas Bahn 2015-02-06 21:02:17 +01:00
parent 1cf41295c7
commit f2a6f0e710
2 changed files with 7 additions and 7 deletions

View File

@ -674,21 +674,21 @@ fn test_encoder() {
let log = Log::new(); let log = Log::new();
let mut wr = Vec::with_capacity(1024); let mut wr = String::with_capacity(1024);
{ {
let mut encoder = rustc_serialize::json::Encoder::new(&mut wr); let mut encoder = rustc_serialize::json::Encoder::new(&mut wr);
log.encode(&mut encoder).unwrap(); log.encode(&mut encoder).unwrap();
} }
assert_eq!(&wr[], JSON_STR.as_bytes()); assert_eq!(&wr[], JSON_STR);
} }
#[bench] #[bench]
fn bench_encoder(b: &mut Bencher) { fn bench_encoder(b: &mut Bencher) {
let log = Log::new(); let log = Log::new();
let mut wr = Vec::with_capacity(1024); let mut wr = String::with_capacity(1024);
{ {
let mut encoder = rustc_serialize::json::Encoder::new(&mut wr); let mut encoder = rustc_serialize::json::Encoder::new(&mut wr);
@ -731,7 +731,7 @@ fn test_serializer_vec() {
log.serialize(&mut serializer).unwrap(); log.serialize(&mut serializer).unwrap();
let json = serializer.unwrap(); let json = serializer.unwrap();
assert_eq!(json.as_slice(), JSON_STR.as_bytes()); assert_eq!(&json[], JSON_STR.as_bytes());
} }
#[bench] #[bench]

View File

@ -982,21 +982,21 @@ fn test_encoder() {
let log = Log::new(); let log = Log::new();
let mut wr = Vec::with_capacity(1024); let mut wr = String::with_capacity(1024);
{ {
let mut encoder = rustc_serialize::json::Encoder::new(&mut wr); let mut encoder = rustc_serialize::json::Encoder::new(&mut wr);
log.encode(&mut encoder).unwrap(); log.encode(&mut encoder).unwrap();
} }
assert_eq!(&wr[], JSON_STR.as_bytes()); assert_eq!(&wr[], JSON_STR);
} }
#[bench] #[bench]
fn bench_encoder(b: &mut Bencher) { fn bench_encoder(b: &mut Bencher) {
let log = Log::new(); let log = Log::new();
let mut wr = Vec::with_capacity(1024); let mut wr = String::with_capacity(1024);
{ {
let mut encoder = rustc_serialize::json::Encoder::new(&mut wr); let mut encoder = rustc_serialize::json::Encoder::new(&mut wr);