Clone on Anymap

I am referring to: anymap - Rust

Is there a way to:

  1. add the restriction of: we can only store types that have Clone defined on them and

  2. add the functionality of allowing the map to be cloned ?

There's already an implementation of Clone for Map: anymap::Map - Rust

I'm missing something obvious. How do I use this?

#[derive(Clone, Debug)]
pub struct Foo {
  pub blah: AnyMap
}

is not compiling for me.

From the documentation:

If you want the entire map to be cloneable, use CloneAny instead of Any.

So instead of AnyMap, which is a type alias for Map<Any>, use Map<CloneAny>.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.