Skip to content

Commit

Permalink
Remove ResourceTable::iter_entries. It was used only by the old `poll…
Browse files Browse the repository at this point in the history
…` implementation. And its is now superseded by take&restore
  • Loading branch information
badeend committed Jan 24, 2024
1 parent fda1966 commit fcc3e87
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions crates/wasmtime/src/component/resource_table.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::Resource;
use std::any::Any;
use std::collections::{BTreeSet, HashMap};
use std::collections::BTreeSet;

#[derive(Debug)]
/// Errors returned by operations on `ResourceTable`
Expand Down Expand Up @@ -417,23 +417,6 @@ impl ResourceTable {
Ok(data)
}

/// Zip the values of the map with mutable references to table entries corresponding to each
/// key. As the keys in the [HashMap] are unique, this iterator can give mutable references
/// with the same lifetime as the mutable reference to the [ResourceTable].
pub fn iter_entries<'a, T>(
&'a mut self,
map: HashMap<u32, T>,
) -> impl Iterator<Item = (Result<&'a mut dyn Any, ResourceTableError>, T)> {
map.into_iter().map(move |(k, v)| {
let item = self
.occupied_mut(k)
.map(|e| e.slot.unwrap_mut())
// Safety: extending the lifetime of the mutable reference.
.map(|item| unsafe { &mut *(item as *mut dyn Any) });
(item, v)
})
}

/// Iterate over all children belonging to the provided parent
pub fn iter_children<T>(
&self,
Expand Down

0 comments on commit fcc3e87

Please sign in to comment.