Repository: servo/servo
File: components/config/opts.rs (Rust)

Code before:
    pub scroll_tree: bool,

    /// Log the display list after each layout.
    pub display_list: bool,

    /// Log notifications when a relayout occurs.
    pub relayout_event: bool,

    /// Periodically log on which events script threads spend their processing time.
    pub profile_script_events: bool,

    /// Log style sharing cache statistics to after each restyle.
    ///
    /// Shows hit/miss statistics for the style sharing cache
    pub style_statistics: bool,

    /// Log garbage collection passes and their durations.
    pub gc_profile: bool,
}

impl DiagnosticsLogging {
    /// Parse diagnostic options from a comma-separated string.
    ///
    /// Returns a configured `DiagnosticsLogging` instance. If the string contains
    /// "help", this will print available options and exit the program.
    pub fn parse_from_string(options_string: &str) -> Result<Self, String> {
        let mut config = Self {
            help: false,
            style_tree: false,
            rule_tree: false,
            flow_tree: false,
            stacking_context_tree: false,
            scroll_tree: false,
            display_list: false,
            relayout_event: false,
            profile_script_events: false,
            style_statistics: false,
            gc_profile: false,
        };

        for option in options_string.split(',') {
            let option = option.trim();
            match option {
                "help" => config.help = true,
                "display-list" => config.display_list = true,
                "stacking-context-tree" => config.stacking_context_tree = true,
                "flow-tree" => config.flow_tree = true,
                "rule-tree" => config.rule_tree = true,
                "style-tree" => config.style_tree = true,
                "style-stats" => config.style_statistics = true,
                "scroll-tree" => config.scroll_tree = true,

Review comment (suggestion):
I think you should call this `extend_from_string` and have the signature be: `pub fn extend_from_string(&mut self, option_string: &str)` and then you could get rid of `extend` completely.

Code after:
    /// Displays the hierarchy of scrollable areas and their properties.
    pub scroll_tree: bool,

    /// Log the display list after each layout.
    pub display_list: bool,

    /// Log notifications when a relayout occurs.
    pub relayout_event: bool,

    /// Periodically log on which events script threads spend their processing time.
    pub profile_script_events: bool,

    /// Log style sharing cache statistics to after each restyle.
    ///
    /// Shows hit/miss statistics for the style sharing cache
    pub style_statistics: bool,

    /// Log garbage collection passes and their durations.
    pub gc_profile: bool,
}

impl DiagnosticsLogging {
    /// Create a new DiagnosticsLogging configuration.
    ///
    /// In non-production builds, this will automatically read and parse the
    /// SERVO_DIAGNOSTICS environment variable if it is set.
    pub fn new() -> Self {
        let mut config: DiagnosticsLogging = Default::default();

        // Disabled for production builds
        #[cfg(debug_assertions)]
        {
            if let Ok(diagnostics_var) = std::env::var("SERVO_DIAGNOSTICS") {
                if let Err(error) = config.extend_from_string(&diagnostics_var) {
                    eprintln!("Could not parse debug logging option: {error}");
                }
            }
        }

        config
    }

    /// Print available diagnostic logging options and their descriptions.
    fn print_debug_options_usage(app: &str) {
        fn print_option(name: &str, description: &str) {
            println!("\t{:<35} {}", name, description);
        }

        println!(
            "Usage: {} debug option,[options,...]\n\twhere options include\n\nOptions:",
            app