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

[bind] Provide a way to transform values during the bind #3

Closed
jkb0o opened this issue Nov 30, 2022 · 0 comments
Closed

[bind] Provide a way to transform values during the bind #3

jkb0o opened this issue Nov 30, 2022 · 0 comments
Milestone

Comments

@jkb0o
Copy link
Owner

jkb0o commented Nov 30, 2022

For now you can bind only values of the same type:

bind!(player, Player.name => name, Label.value)

The Player.name and Label.value are string types.
It should be possile to provide some transformer to the bind:

bind!(player, Health.value => |v| format!("Health:  {}", v) => label, Label.value)

While the general form should cover all cases, I believe the format! is the most often scenario, so bind! macro should treat string literals as format. The previous example will looks like this:

bind!(player, Health.value => "Health:  {}" => label, Label.value)

From my point of view, transformers should be a part of BindTo only, but looks like it is much simpler to make them a part of BindFrom, at least as the first step.

@jkb0o jkb0o closed this as completed in 1318f7d Dec 14, 2022
@jkb0o jkb0o added this to the [0.1.0] MVP milestone Dec 16, 2022
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

1 participant