diff options
author | Martin Robinson <mrobinson@igalia.com> | 2025-03-13 13:00:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-13 12:00:31 +0000 |
commit | 294a649a6c96ea0fba05fad59a41dea6c7f1d66d (patch) | |
tree | 5b3de846c3e4954ff7e4d3af666d3c82108b09f9 /components/shared/profile/time.rs | |
parent | 959720db0a15d207e31e44ffd58d76e9e31b18c9 (diff) | |
download | servo-294a649a6c96ea0fba05fad59a41dea6c7f1d66d.tar.gz servo-294a649a6c96ea0fba05fad59a41dea6c7f1d66d.zip |
Use `strum` to iterate through enum variants and get their names (#35933)
`strum` allows us to avoid manually listing enum variant names and also
to get their names as static strings. We cannot use this for all cases
due to https://github.com/Peternator7/strum/issues/152, but we can
still use it to remove a lot of code.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/shared/profile/time.rs')
-rw-r--r-- | components/shared/profile/time.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/components/shared/profile/time.rs b/components/shared/profile/time.rs index 78c380b70dc..0531b68e09e 100644 --- a/components/shared/profile/time.rs +++ b/components/shared/profile/time.rs @@ -7,6 +7,7 @@ use ipc_channel::ipc::IpcSender; use log::warn; use serde::{Deserialize, Serialize}; use servo_config::opts; +use strum_macros::IntoStaticStr; use time::Duration; #[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] @@ -57,7 +58,9 @@ pub enum ProfilerMsg { /// Usage sites of variants marked “Rust tracing only” are not visible to rust-analyzer. #[repr(u32)] -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] +#[derive( + Clone, Copy, Debug, Deserialize, Eq, Hash, IntoStaticStr, Ord, PartialEq, PartialOrd, Serialize, +)] pub enum ProfilerCategory { /// The compositor is rasterising or presenting. /// |