How to actually use this
Opened this issue · 4 comments
I want to crate a Map<Component>
, but whatever I do, Rust always says error[E0277]: the trait bound `Component + 'static: anymap::any::UncheckedAnyExt` is not satisfied
.
I have tried so much now:
pub trait Component {
pub trait Component: std::any::Any {
pub trait Component: anymap::any::Any {
pub trait Component: anymap::any::Any + anymap::any::UncheckedAnyExt {
pub trait Component: 'static + anymap::any::Any + anymap::any::UncheckedAnyExt {
pub trait Component: 'static + std::any::Any + anymap::any::Any + anymap::any::UncheckedAnyExt {
I am lost on what to do...
Map
is generic specifically for the Clone
and concurrency features; the types that are designed to slot in there are Any
, Any + Send + Sync
, CloneAny
, &c., with the full list of all eight here.
I’ve thought about making it compatible with custom Any
types—such as with mopa
—but that would be a rather substantial change to the approach employed, and I haven’t seen any evidence that people would gain benefit from it. Would you?
It would very much help given I only want to allow types implementing Component into the map. That said, if it's outside of the scope of this crate, I am fine with implementing it myself, of course.
@Binero I know this was ages ago, but do you have an implementation you could share? I have the same sort of need.
I had assumed this was possible and was planning clap around it. My plan for clap was to have multiple anymap's and wanted them to be typed so people can only use types designed for each one.
See clap-rs/clap#3476 for more details on my thoughts for clap.
I believe I'll also need IntoBox
public so I can provide my own getters / setters since I won't be directly exposing the anymap