Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to actually use this #29

Open
Binero opened this issue Feb 5, 2017 · 4 comments
Open

How to actually use this #29

Binero opened this issue Feb 5, 2017 · 4 comments

Comments

@Binero
Copy link

Binero commented Feb 5, 2017

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...

@chris-morgan
Copy link
Owner

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?

@Binero
Copy link
Author

Binero commented Feb 6, 2017

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.

@fletching
Copy link

@Binero I know this was ages ago, but do you have an implementation you could share? I have the same sort of need.

@epage
Copy link

epage commented Apr 2, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants