-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Allow tuples in add_plugins
.
#7687
Conversation
Hmm. Very interesting, but I think ultimately a regression. It's a lot harder for users to understand exactly what they need to pass in, or what existing code is doing. |
Okay, I have changed the code to make
This does not any longer fix the problem in #7631, but would still help implementing #7682. |
add_plugins
.
add_plugins
.add_plugins
. [Was formerly: Add add method to App]
Definitely like that better! |
add_plugins
. [Was formerly: Add add method to App]add_plugins
.
I have moved the traits into their corresponding module and added additional tests and documentations for the traits. |
Superseded by #8097. |
As far as i understand, the other pr will not help with the ownership issues i ran into in #7682, though... Is there another solution for that? |
I didn't include it because it felt somewhat hacky to solve the problem in this way, I believe the better approach would be to change |
Making |
Alright, thanks for looking into it :) Sounds like a decent compromise. |
Objective
This is just a small idea of mine about a possible unified API.(see #7687 (comment))
Solution
(see #7687 (comment))
Add a single. Plugins that need resources to be inserted before they can be built (because they don't want to use an ugly hack likeadd
method to which aPlugin
, aPluginGroup
or aFnOnce(&mut App)
can be passedArc<Mutex<Option<T>>>
) can now provide an constructor that returns anFnOnce
which takes care of that (seelogger_example
).Pros:
add_plugins
.Added Flexibility: Application code can easily and ergonomically split up setup code into functions that take an &mut App parameter.Users don't have to worry about the difference ofadd_plugin
vsadd_plugins
Shorter to write:app.add_plugins(DefaultPlugins)
vsapp.add(DefaultPlugins)
. The type names already make clear that Plugins are added.Cons:Redundancy on the API level. This can be solved by removingadd_plugin
andadd_plugins
or reducing their visibility.