From 13ff28d2472675ea7d35889adb8aa48f4b9a4ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20Dupr=C3=A9=20Bertoni?= Date: Mon, 25 Apr 2022 12:41:42 +0300 Subject: [PATCH 1/2] Update itoa to 1.0 --- Cargo.toml | 2 +- src/serializer.rs | 31 ++----------------------------- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f6fd3178..2e94f956 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ encoding_rs = "0.8" [dependencies] cssparser-macros = {path = "./macros", version = "0.6"} dtoa-short = "0.3" -itoa = "0.4" +itoa = "1.0" matches = "0.1" phf = {version = "0.10", features = ["macros"]} serde = {version = "1.0", optional = true} diff --git a/src/serializer.rs b/src/serializer.rs index 9cde6dc8..a13602ad 100644 --- a/src/serializer.rs +++ b/src/serializer.rs @@ -6,7 +6,6 @@ use dtoa_short::{self, Notation}; use itoa; use matches::matches; use std::fmt::{self, Write}; -use std::io; use std::str; use super::Token; @@ -342,34 +341,8 @@ macro_rules! impl_tocss_for_int { where W: fmt::Write, { - struct AssumeUtf8(W); - - impl io::Write for AssumeUtf8 { - #[inline] - fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { - // Safety: itoa only emits ASCII, which is also well-formed UTF-8. - debug_assert!(buf.is_ascii()); - self.0 - .write_str(unsafe { str::from_utf8_unchecked(buf) }) - .map_err(|_| io::ErrorKind::Other.into()) - } - - #[inline] - fn write(&mut self, buf: &[u8]) -> io::Result { - self.write_all(buf)?; - Ok(buf.len()) - } - - #[inline] - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } - } - - match itoa::write(AssumeUtf8(dest), *self) { - Ok(_) => Ok(()), - Err(_) => Err(fmt::Error), - } + let mut buf = itoa::Buffer::new(); + dest.write_str(buf.format(*self)) } } }; From 7b4f6787a1c10dc0d51c42cdff089ef256361e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 18 May 2022 14:10:51 +0200 Subject: [PATCH 2/2] Bump version. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2e94f956..bda0cf1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cssparser" -version = "0.29.3" +version = "0.29.4" authors = [ "Simon Sapin " ] description = "Rust implementation of CSS Syntax Level 3"