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 likeaddmethod to which aPlugin, aPluginGroupor aFnOnce(&mut App)can be passedArc<Mutex<Option<T>>>) can now provide an constructor that returns anFnOncewhich 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_pluginvsadd_pluginsShorter 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_pluginandadd_pluginsor reducing their visibility.