Skip to content

Commit 47f939c

Browse files
author
bors-servo
authored
Auto merge of #221 - servo:serialize-name, r=SimonSapin
Expose serializer::serialize_name. I want to use it to remove some stupid allocations in Servo, which effectively do: serialize_identifier(format!("--{}", custom_prop_name)); And could do instead: write_str("--"); serialize_name(custom_prop_name); <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-cssparser/221) <!-- Reviewable:end -->
2 parents c512fa3 + b4d5e05 commit 47f939c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cssparser"
3-
version = "0.23.7"
3+
version = "0.23.8"
44
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]
55

66
description = "Rust implementation of CSS Syntax Level 3"

src/serializer.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,11 @@ pub fn serialize_identifier<W>(mut value: &str, dest: &mut W) -> fmt::Result whe
188188
}
189189
}
190190

191-
192-
fn serialize_name<W>(value: &str, dest: &mut W) -> fmt::Result where W:fmt::Write {
191+
/// Write a CSS name, like a custom property name.
192+
///
193+
/// You should only use this when you know what you're doing, when in doubt,
194+
/// consider using `serialize_identifier`.
195+
pub fn serialize_name<W>(value: &str, dest: &mut W) -> fmt::Result where W:fmt::Write {
193196
let mut chunk_start = 0;
194197
for (i, b) in value.bytes().enumerate() {
195198
let escaped = match b {

0 commit comments

Comments
 (0)