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>
This commit is contained in:
Martin Robinson 2025-03-13 13:00:31 +01:00 committed by GitHub
parent 959720db0a
commit 294a649a6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 51 additions and 285 deletions

View file

@ -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.
///