diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index a51b8b7612d..467bccddd1e 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -144,7 +144,7 @@ fn run_server( }); // A token shared with the embedder to bypass permission prompt. - let token = format!("{:X}", servo_rand::ServoRng::new().next_u32()); + let token = format!("{:X}", servo_rand::ServoRng::default().next_u32()); let port = bound.as_ref().map(|(_, port)| *port).ok_or(()); embedder.send((None, EmbedderMsg::OnDevtoolsStarted(port, token.clone()))); diff --git a/components/rand/lib.rs b/components/rand/lib.rs index 260ff2c259a..042736ed5af 100644 --- a/components/rand/lib.rs +++ b/components/rand/lib.rs @@ -95,12 +95,12 @@ impl ServoRng { } } -impl ServoRng { +impl Default for ServoRng { /// Create an auto-reseeding instance of `ServoRng`. /// /// This uses the shared `OsRng`, so avoids consuming /// a file descriptor. - pub fn new() -> ServoRng { + fn default() -> Self { trace!("Creating new ServoRng."); let mut os_rng = OS_RNG.lock().expect("Poisoned lock."); let isaac_rng = IsaacCore::from_rng(&mut *os_rng).unwrap(); @@ -156,7 +156,7 @@ pub fn thread_rng() -> ServoThreadRng { } thread_local! { - static SERVO_THREAD_RNG: ServoThreadRng = ServoThreadRng { rng: Rc::new(RefCell::new(ServoRng::new())) }; + static SERVO_THREAD_RNG: ServoThreadRng = ServoThreadRng { rng: Rc::new(RefCell::new(ServoRng::default())) }; } impl RngCore for ServoThreadRng { diff --git a/components/script/dom/crypto.rs b/components/script/dom/crypto.rs index e337c6ebb01..6abc8b36fa9 100644 --- a/components/script/dom/crypto.rs +++ b/components/script/dom/crypto.rs @@ -29,7 +29,7 @@ impl Crypto { fn new_inherited() -> Crypto { Crypto { reflector_: Reflector::new(), - rng: DomRefCell::new(ServoRng::new()), + rng: DomRefCell::new(ServoRng::default()), } } diff --git a/components/shared/net/lib.rs b/components/shared/net/lib.rs index 63f4e7d8710..e69bd4a317b 100644 --- a/components/shared/net/lib.rs +++ b/components/shared/net/lib.rs @@ -862,5 +862,5 @@ impl WebrenderIpcSender { } lazy_static! { - pub static ref PRIVILEGED_SECRET: u32 = servo_rand::ServoRng::new().next_u32(); + pub static ref PRIVILEGED_SECRET: u32 = servo_rand::ServoRng::default().next_u32(); }