aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkomuhangi <51232461+jahielkomu@users.noreply.github.com>2024-03-27 13:15:15 +0300
committerGitHub <noreply@github.com>2024-03-27 10:15:15 +0000
commit29f796a1ded8cf14ebae3b351bc6ec618a5c822f (patch)
tree5506e927d57053a8a7885d84183b312fad3b378f
parent9b50a6be776ab3223f130deb471d89f6313670d3 (diff)
downloadservo-29f796a1ded8cf14ebae3b351bc6ec618a5c822f.tar.gz
servo-29f796a1ded8cf14ebae3b351bc6ec618a5c822f.zip
clippy: Fix some warnings in `components/script/timers.rs` (#31878)
* Fixed some clippy warnings in components/script/timers.rs * Formatted changes in components/script/timers.rs * Updated changes in components/script/timers.rs * Updated Default implementation of JsTimers in components/script/timers.rs * UPDATED DEFAULT METHOD IMPLEMENTATION OF JsTimers in components/script/timers.rs
-rw-r--r--components/script/timers.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/components/script/timers.rs b/components/script/timers.rs
index e63bc79f84e..7dabbd5a5fa 100644
--- a/components/script/timers.rs
+++ b/components/script/timers.rs
@@ -124,14 +124,14 @@ impl PartialOrd for OneshotTimer {
impl Eq for OneshotTimer {}
impl PartialEq for OneshotTimer {
fn eq(&self, other: &OneshotTimer) -> bool {
- self as *const OneshotTimer == other as *const OneshotTimer
+ std::ptr::eq(self, other)
}
}
impl OneshotTimers {
pub fn new(scheduler_chan: IpcSender<TimerSchedulerMsg>) -> OneshotTimers {
OneshotTimers {
- js_timers: JsTimers::new(),
+ js_timers: JsTimers::default(),
timer_event_chan: DomRefCell::new(None),
scheduler_chan,
next_timer_handle: Cell::new(OneshotTimerHandle(1)),
@@ -194,7 +194,7 @@ impl OneshotTimers {
fn is_next_timer(&self, handle: OneshotTimerHandle) -> bool {
match self.timers.borrow().last() {
None => false,
- Some(ref max_timer) => max_timer.handle == handle,
+ Some(max_timer) => max_timer.handle == handle,
}
}
@@ -418,8 +418,8 @@ enum InternalTimerCallback {
),
}
-impl JsTimers {
- pub fn new() -> JsTimers {
+impl Default for JsTimers {
+ fn default() -> Self {
JsTimers {
next_timer_handle: Cell::new(JsTimerHandle(1)),
active_timers: DomRefCell::new(HashMap::new()),
@@ -427,7 +427,9 @@ impl JsTimers {
min_duration: Cell::new(None),
}
}
+}
+impl JsTimers {
// see https://html.spec.whatwg.org/multipage/#timer-initialisation-steps
pub fn set_timeout_or_interval(
&self,