You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Closes#254, Documentation updates
* Improvements to #254
* Update crates/timers/src/callback.rs
Co-authored-by: Muhammad Hamza <[email protected]>
* Update crates/timers/src/callback.rs
Co-authored-by: Muhammad Hamza <[email protected]>
* Update crates/timers/src/callback.rs
Co-authored-by: Muhammad Hamza <[email protected]>
* Update callback.rs
Co-authored-by: Spencer C. Imbleau <[email protected]>
Co-authored-by: Muhammad Hamza <[email protected]>
Copy file name to clipboardExpand all lines: crates/timers/src/callback.rs
+10-6Lines changed: 10 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -23,8 +23,8 @@ extern "C" {
23
23
///
24
24
/// See `Timeout::new` for scheduling new timeouts.
25
25
///
26
-
/// Once scheduled, you can either `cancel` so that it doesn't run or `forget`
27
-
/// it so that it is un-cancel-able.
26
+
/// Once scheduled, you can [`drop`] the [`Timeout`] to clear it or [`forget`](Timeout::forget) to leak it. Once forgotten, the interval will keep running forever.
27
+
/// This pattern is known as Resource Acquisition Is Initialization (RAII).
28
28
#[derive(Debug)]
29
29
#[must_use = "timeouts cancel on drop; either call `forget` or `drop` explicitly"]
30
30
pubstructTimeout{
@@ -33,6 +33,8 @@ pub struct Timeout {
33
33
}
34
34
35
35
implDropforTimeout{
36
+
/// Disposes of the timeout, dually cancelling this timeout by calling
37
+
/// `clearTimeout` directly.
36
38
fndrop(&mutself){
37
39
ifletSome(id) = self.id{
38
40
clear_timeout(id);
@@ -71,7 +73,7 @@ impl Timeout {
71
73
}
72
74
}
73
75
74
-
/// Make this timeout uncancel-able.
76
+
/// Forgets this resource without clearing the timeout.
75
77
///
76
78
/// Returns the identifier returned by the original `setTimeout` call, and
77
79
/// therefore you can still cancel the timeout by calling `clearTimeout`
@@ -123,8 +125,8 @@ impl Timeout {
123
125
///
124
126
/// See `Interval::new` for scheduling new intervals.
125
127
///
126
-
/// Once scheduled, you can either `cancel` so that it ceases to fire or `forget`
127
-
/// it so that it is un-cancel-able.
128
+
/// Once scheduled, you can [`drop`] the [`Interval`] to clear it or [`forget`](Interval::forget) to leak it. Once forgotten, the interval will keep running forever.
129
+
/// This pattern is known as Resource Acquisition Is Initialization (RAII).
128
130
#[derive(Debug)]
129
131
#[must_use = "intervals cancel on drop; either call `forget` or `drop` explicitly"]
130
132
pubstructInterval{
@@ -133,6 +135,8 @@ pub struct Interval {
133
135
}
134
136
135
137
implDropforInterval{
138
+
/// Disposes of the interval, dually cancelling this interval by calling
139
+
/// `clearInterval` directly.
136
140
fndrop(&mutself){
137
141
ifletSome(id) = self.id{
138
142
clear_interval(id);
@@ -170,7 +174,7 @@ impl Interval {
170
174
}
171
175
}
172
176
173
-
/// Make this interval uncancel-able.
177
+
/// Forget this resource without clearing the interval.
174
178
///
175
179
/// Returns the identifier returned by the original `setInterval` call, and
176
180
/// therefore you can still cancel the interval by calling `clearInterval`
0 commit comments