diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-04-18 18:00:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-18 18:00:14 -0400 |
commit | a64e63c3614b98aa2b51fb6b7ef4e30251e03111 (patch) | |
tree | be380bdc2d7c61126c594708aa97cacede9b6316 /core | |
parent | ca3b20df3c270f1bf5f1a7980c083c22a590420d (diff) |
perf: move Deno.writeTextFile and like functions to Rust (#14221)
Co-authored-by: Luca Casonato <hello@lcas.dev>
Diffstat (limited to 'core')
-rw-r--r-- | core/async_cancel.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/async_cancel.rs b/core/async_cancel.rs index e8f25136c..cf338174d 100644 --- a/core/async_cancel.rs +++ b/core/async_cancel.rs @@ -1,6 +1,7 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. use crate::RcLike; +use crate::Resource; use futures::future::FusedFuture; use futures::future::Future; use futures::future::TryFuture; @@ -8,6 +9,7 @@ use futures::task::Context; use futures::task::Poll; use pin_project::pin_project; use std::any::type_name; +use std::borrow::Cow; use std::error::Error; use std::fmt; use std::fmt::Display; @@ -84,6 +86,16 @@ impl<F: Future> FusedFuture for Cancelable<F> { } } +impl Resource for CancelHandle { + fn name(&self) -> Cow<str> { + "cancellation".into() + } + + fn close(self: Rc<Self>) { + self.cancel(); + } +} + #[pin_project(project = TryCancelableProjection)] #[derive(Debug)] pub struct TryCancelable<F> { |