Skip to content

gloo_timers, ambiguous verbage #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 23, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions crates/timers/src/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ extern "C" {
///
/// See `Timeout::new` for scheduling new timeouts.
///
/// Once scheduled, you can either `cancel` so that it doesn't run or `forget`
/// it so that it is un-cancel-able.
/// Resource Acquisition Is Initialization (RAII). Once scheduled, you can
/// `cancel`/`drop` it or `forget` it to free memory, remaining scheduled.
#[derive(Debug)]
#[must_use = "timeouts cancel on drop; either call `forget` or `drop` explicitly"]
pub struct Timeout {
Expand All @@ -33,6 +33,8 @@ pub struct Timeout {
}

impl Drop for Timeout {
/// Disposes of the timeout, dually cancelling this timeout by calling
/// `clearTimeout` directly.
fn drop(&mut self) {
if let Some(id) = self.id {
clear_timeout(id);
Expand Down Expand Up @@ -71,7 +73,7 @@ impl Timeout {
}
}

/// Make this timeout uncancel-able.
/// Drops this resource without clearing the timeout.
///
/// Returns the identifier returned by the original `setTimeout` call, and
/// therefore you can still cancel the timeout by calling `clearTimeout`
Expand Down Expand Up @@ -123,8 +125,8 @@ impl Timeout {
///
/// See `Interval::new` for scheduling new intervals.
///
/// Once scheduled, you can either `cancel` so that it ceases to fire or `forget`
/// it so that it is un-cancel-able.
/// Resource Acquisition Is Initialization (RAII). Once scheduled, you can
/// `cancel`/`drop` it or `forget` it to free memory, remaining scheduled.
#[derive(Debug)]
#[must_use = "intervals cancel on drop; either call `forget` or `drop` explicitly"]
pub struct Interval {
Expand All @@ -133,6 +135,8 @@ pub struct Interval {
}

impl Drop for Interval {
/// Disposes of the interval, dually cancelling this interval by calling
/// `clearInterval` directly.
fn drop(&mut self) {
if let Some(id) = self.id {
clear_interval(id);
Expand Down Expand Up @@ -170,7 +174,7 @@ impl Interval {
}
}

/// Make this interval uncancel-able.
/// Drops this resource without clearing the interval.
///
/// Returns the identifier returned by the original `setInterval` call, and
/// therefore you can still cancel the interval by calling `clearInterval`
Expand Down