Skip to content

Commit 91cf14c

Browse files
committed
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);
1 parent c512fa3 commit 91cf14c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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)