Skip to content

Commit

Permalink
chore!: Switch to anymap2
Browse files Browse the repository at this point in the history
BREAKING-CHANGE: In one place we do an `Into` to an `anymap` type.  This
is unlikely to break anyone.
  • Loading branch information
epage committed Aug 25, 2021
1 parent 0a273c3 commit b5c1acd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license = "MIT OR Apache-2.0"
edition = "2018"

[dependencies]
anymap = "0.12"
anymap2 = "0.13"
itertools = "0.10.0"
num-traits = "0.2"
pest = "2.0"
Expand Down
8 changes: 3 additions & 5 deletions crates/core/src/runtime/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,15 @@ impl<'g> Default for RuntimeCore<'g> {

/// Unnamed state for plugins during rendering
pub struct Registers {
registers: std::cell::RefCell<anymap::AnyMap>,
registers: std::cell::RefCell<anymap2::AnyMap>,
}

impl Registers {
/// Data store for stateful tags/blocks.
///
/// If a plugin needs state, it creates a `struct Register : Default` and accesses it via
/// `get_mut`.
pub fn get_mut<T: anymap::any::IntoBox<dyn anymap::any::Any> + Default>(
&self,
) -> std::cell::RefMut<'_, T> {
pub fn get_mut<T: std::any::Any + Default>(&self) -> std::cell::RefMut<'_, T> {
std::cell::RefMut::map(self.registers.borrow_mut(), |registers| {
registers.entry::<T>().or_insert_with(Default::default)
})
Expand All @@ -301,7 +299,7 @@ impl Registers {
impl Default for Registers {
fn default() -> Self {
Self {
registers: std::cell::RefCell::new(anymap::AnyMap::new()),
registers: std::cell::RefCell::new(anymap2::AnyMap::new()),
}
}
}
Expand Down

0 comments on commit b5c1acd

Please sign in to comment.