-
Notifications
You must be signed in to change notification settings - Fork 5
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
Implement Input
for stdlib types that implement Display
#132
Comments
I think this is overall a good idea. But I'm hesitant to implement it right away without a concrete situation where someone wants this. For two reasons:
Did you find yourself in a situation where you wanted a particular |
I think that's fair. I don't have a particular use case, it just seems like something that would be nice. What do you think about leaving issues like this open? I tend to leave open issues with enhancements that I'm likely to implement, but don't yet have a plan to implement, but I have mixed feelings about whether that's a good idea or not. I think the advantage here is that if someone wants this, they can add a comment, when otherwise they might not. The disadvantage is that it clutters the issues. I'm kinda torn. |
I would leave this open. People can then either chime in (ideally with a concrete use-case) or react with a thumbs-up (to the initial comment). |
I recently wanted to do something like this: let bytes = 1024;
cmd_unit!(%"something -n", bytes); I'm not sure this would have worked with any possible impls proposed in this issue. Because the type of (Just leaving this comment here since I think the solution to this issue should take this into account.) |
I think it would actually work. Bare integers default to u32, so the impl for u32 woudl have been invoked. I tried it out, and this prints trait Foo {
fn bar(self);
}
impl Foo for u32 {
fn bar(self) {
println!("Hello, world!");
}
}
fn main() {
100.bar();
} |
We talked about having a blanket impl of
Input
for things that implementDisplay
, but there are lots of problems with that, so we sort of abandoned it.It might still be nice, however, to have
Input
implementations for stdlib types that implementDisplay
, so you can do things like pass numbers to commands.What do you think of us just providing the impls?
We could do it with a macro, something like:
Or all in one item:
The text was updated successfully, but these errors were encountered: