mirror of
https://github.com/servo/servo.git
synced 2025-06-13 02:44:29 +00:00
Consolidated opts into a manual Default trait implementation (#35257)
Signed-off-by: Shalvin Deo <shalvin.deo@live.com>
This commit is contained in:
parent
cdd6660113
commit
ec6c4bc8fd
1 changed files with 34 additions and 32 deletions
|
@ -15,7 +15,7 @@ use servo_geometry::DeviceIndependentPixel;
|
|||
use servo_url::ServoUrl;
|
||||
|
||||
/// Global flags for Servo, currently set on the command line.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Opts {
|
||||
/// Whether or not the legacy layout system is enabled.
|
||||
pub legacy_layout: bool,
|
||||
|
@ -207,8 +207,9 @@ pub enum OutputOptions {
|
|||
Stdout(f64),
|
||||
}
|
||||
|
||||
pub fn default_opts() -> Opts {
|
||||
Opts {
|
||||
impl Default for Opts {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
legacy_layout: false,
|
||||
time_profiling: None,
|
||||
time_profiler_trace_path: None,
|
||||
|
@ -238,12 +239,13 @@ pub fn default_opts() -> Opts {
|
|||
unminify_css: false,
|
||||
print_pwm: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make Opts available globally. This saves having to clone and pass
|
||||
// opts everywhere it is used, which gets particularly cumbersome
|
||||
// when passing through the DOM structures.
|
||||
static OPTIONS: LazyLock<RwLock<Opts>> = LazyLock::new(|| RwLock::new(default_opts()));
|
||||
static OPTIONS: LazyLock<RwLock<Opts>> = LazyLock::new(|| RwLock::new(Opts::default()));
|
||||
|
||||
pub fn set_options(opts: Opts) {
|
||||
*OPTIONS.write().unwrap() = opts;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue