matklad / xshell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot interpolate numerical values with cmd! macro

stevedonovan opened this issue · comments

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?

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?

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.