Skip to content

Commit f65b6f4

Browse files
committed
The manually implemented Default trait for CancellationTokenSource has been removed and replaced with an automatically generated #[derive(Default)]. The implementation of the CancellationTokenSource::new method has also been simplified.
1 parent 3d867d6 commit f65b6f4

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

src/lib.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct Inner {
100100
/// cts.cancel();
101101
/// assert!(cts.is_cancelled());
102102
/// ```
103-
#[derive(Clone)]
103+
#[derive(Default, Clone)]
104104
pub struct CancellationTokenSource {
105105
inner: Rc<Inner>,
106106
}
@@ -142,18 +142,10 @@ impl Display for Cancelled {
142142

143143
impl Error for Cancelled {}
144144

145-
impl Default for CancellationTokenSource {
146-
fn default() -> Self {
147-
Self::new()
148-
}
149-
}
150-
151145
impl CancellationTokenSource {
152146
/// Create a new `CancellationTokenSource`.
153147
pub fn new() -> Self {
154-
Self {
155-
inner: Rc::new(Inner::default()),
156-
}
148+
Default::default()
157149
}
158150

159151
/// Get a `CancellationToken` associated with this source.

0 commit comments

Comments
 (0)