-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Export Optionality
markers
#203
Conversation
In order to support custom implementations of `YarnFnParam`, `Optional` and `Required` need to be exported. This exports `yarnspinner_core::yarn_fn::optionality` as `yarnspinner_core::prelude::optionality` and seals the `AllowedOptionalityChain` trait so it cannot be implemented.
Huh, I was even considering explicitly sealing |
18c9ea9
to
a0ae393
Compare
@janhohenheim If you decide to merge this then I intend to do a follow-up PR to change @zmbush Would you be okay with me pushing that change onto this PR? |
It's nice to have for convenience. I have a bunch of types that I use as command arguments, and instead of taking them as Strings, it's nice to be able to do something like: #[yarn_command(dialog_runner)]
fn set_background(
In((new_bg, mode)): In<(Location, ShowOption)>,
...
) {
...
} instead of #[yarn_command(dialog_runner)]
fn set_background(
In((new_bg, mode)): In<(String, String)>,
...
) {
let new_bg: Location = new_bg.parse().unwrap();
let mode: ShowOption = mode.parse().unwrap();
...
} |
@zmbush I see! I was thinking about making automatic parsing a feature as well, so this workaround is completely valid. I'll merge @bash's counteroffer when it's ready :) Btw, what's that fn register_set_background(mut dialog_runner: Query<&mut DialogueRunner, Added<DialogueRunner>>) {
for mut dialog_runner in dialog_runner.iter_mut() {
dialog_runner.commands_mut().add_command("set_background", set_background);
}
} |
@janhohenheim Yeah, that's essentially what it does. It actually started as a way to generate |
Yeah, generating The macro looks nice! I wouldn't upstream it since I prefer to expose exactly one way to configure stuff, but I am tempted to replicate it for my own project :D BTW, please ping me if you publish anything using the crate, I'd love to see what cool stuff people create with it :) |
Never mind, associated consts and |
@zmbush I assume sealing |
@janhohenheim / @bash Sealing |
In order to support custom implementations of
YarnFnParam
,Optional
andRequired
need to be exported.This exports
yarnspinner_core::yarn_fn::optionality
asyarnspinner_core::prelude::optionality
and seals theAllowedOptionalityChain
trait so it cannot be implemented.