diff options
Diffstat (limited to 'core/async_cell.rs')
-rw-r--r-- | core/async_cell.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/async_cell.rs b/core/async_cell.rs index d11b83932..cd6c51682 100644 --- a/core/async_cell.rs +++ b/core/async_cell.rs @@ -1,10 +1,14 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +use std::any::type_name; use std::any::Any; use std::borrow::Borrow; use std::cell::Cell; use std::cell::UnsafeCell; use std::collections::VecDeque; +use std::fmt; +use std::fmt::Debug; +use std::fmt::Formatter; use std::ops::Deref; use std::rc::Rc; @@ -45,6 +49,17 @@ impl<T: 'static> AsyncRefCell<T> { pub fn as_ptr(&self) -> *mut T { self.value.get() } + + pub fn into_inner(self) -> T { + assert!(self.borrow_count.get().is_empty()); + self.value.into_inner() + } +} + +impl<T> Debug for AsyncRefCell<T> { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + write!(f, "AsyncRefCell<{}>", type_name::<T>()) + } } impl<T: Default + 'static> Default for AsyncRefCell<T> { |