diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-11-07 15:59:02 +0100 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2019-11-07 09:59:02 -0500 |
commit | 415d4c2e5236f6d8dfef8865b1665f144c39a019 (patch) | |
tree | e7c936d97d077c6ba1ce79b495894d182299c96f /core/resources.rs | |
parent | f466ef97061ffed5baf1612a646accb2cda4b772 (diff) |
refactor: rewrite accept resources (#3271)
Diffstat (limited to 'core/resources.rs')
-rw-r--r-- | core/resources.rs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/core/resources.rs b/core/resources.rs index 1ba061d0b..a66fb9120 100644 --- a/core/resources.rs +++ b/core/resources.rs @@ -69,18 +69,14 @@ impl ResourceTable { // close(2) is done by dropping the value. Therefore we just need to remove // the resource from the RESOURCE_TABLE. pub fn close(&mut self, rid: ResourceId) -> Option<()> { - if let Some((_name, resource)) = self.map.remove(&rid) { - resource.close(); - return Some(()); - } - None + self.map.remove(&rid).map(|(_name, _resource)| ()) } } /// Abstract type representing resource in Deno. -pub trait Resource: Downcast + Any + Send { - /// Method that allows to cleanup resource. - // TODO(ry) remove this method. Resources should rely on drop trait instead. - fn close(&self) {} -} +/// +/// The only thing it does is implementing `Downcast` trait +/// that allows to cast resource to concrete type in `TableResource::get` +/// and `TableResource::get_mut` methods. +pub trait Resource: Downcast + Any + Send {} impl_downcast!(Resource); |