Converted serialization methods to implement the to_css trait, writing to string buffers to save string allocations for every result

This commit is contained in:
David Raifaizen 2016-03-26 11:02:34 -04:00 committed by Simon Sapin
parent 0985d7563f
commit 51e642e875
4 changed files with 132 additions and 46 deletions

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use cssparser::ToCss;
use rustc_serialize::json::Json;
use std::env;
use std::fs::{File, remove_file};
@ -83,10 +84,10 @@ fn property_declaration_block_should_serialize_correctly() {
important: Arc::new(important)
};
let css_string = block.serialize();
let css_string = block.to_css_string();
assert_eq!(
css_string,
"width: 70px; min-height: 20px; display: inline-block; height: 20px ! important;"
"width: 70px; min-height: 20px; display: inline-block; height: 20px !important;"
);
}