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

Cannot interpolate numerical values with cmd! macro #2

Open
stevedonovan opened this issue Oct 18, 2020 · 2 comments
Open

Cannot interpolate numerical values with cmd! macro #2

stevedonovan opened this issue Oct 18, 2020 · 2 comments

Comments

@stevedonovan
Copy link

the trait `AsRef<OsStr>` is not implemented for `u32`

I can see the point of AsRef<OsStr> since regular strings and paths behave as expected (Display would present a problem), but many external programs take numerical parameters.

I wonder what the consequences are of using Debug instead?

@matklad
Copy link
Owner

matklad commented Oct 18, 2020

Hm yeah, I wouldn’t be opposed if {x} worked if x were of an unsigned integral type.

I don’t think though that such an API is possible without dtolney trick for specialization, and I’d consider that trick to be to complex for current use case.

We might also introduce special syntax here (like we did for splats), but that won’t be discoverable.

A third alternative is to roll our own AsRef trait with a bunch of manual implementations for all types, but then it won’t be compatible with 3rd party impls of AsRef.

But maybe I am missing some good solution here?

@stevedonovan
Copy link
Author

Yes, I agree that you do not want to rush into some complicated machinery at this point. The least complicated way would be a custom AsRef-like trait.

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

2 participants