From 00b3300bcd433617dea1699168ef2fac6a0ce181 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Sat, 15 Feb 2025 11:42:43 +1300 Subject: [PATCH] Implement MallocSizeOf for Au Signed-off-by: Nico Burns --- Cargo.toml | 4 +++- src/app_unit.rs | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f39090c..90d8659 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "app_units" -version = "0.7.6" +version = "0.7.7" authors = ["The Servo Project Developers"] description = "Servo app units type (Au)" documentation = "https://docs.rs/app_units/" @@ -11,6 +11,7 @@ edition = "2021" [dependencies] num-traits = { version = "0.2", optional = true } serde = { version = "1.0", optional = true, features = ["derive"] } +malloc_size_of = { version = "0.1", default-features = false, optional = true } [dev-dependencies] ron = "0.8.0" @@ -19,3 +20,4 @@ ron = "0.8.0" default = ["num_traits", "serde_serialization"] num_traits = ["num-traits"] serde_serialization = ["serde"] +malloc_size_of = ["dep:malloc_size_of"] diff --git a/src/app_unit.rs b/src/app_unit.rs index 07473c9..79d0e37 100644 --- a/src/app_unit.rs +++ b/src/app_unit.rs @@ -2,6 +2,8 @@ * 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/. */ +#[cfg(feature = "malloc_size_of")] +use malloc_size_of::malloc_size_of_is_0; #[cfg(feature = "num_traits")] use num_traits::Zero; #[cfg(feature = "serde_serialization")] @@ -40,6 +42,9 @@ impl fmt::Debug for Au { } } +#[cfg(feature = "malloc_size_of")] +malloc_size_of_is_0!(Au); + #[cfg(feature = "serde_serialization")] impl<'de> Deserialize<'de> for Au { fn deserialize>(deserializer: D) -> Result {