-
Notifications
You must be signed in to change notification settings - Fork 135
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
Would removing (or moving) Num::from_str_radix() be ever considered? #192
Comments
That's the messy history of the I don't intend to make breaking changes to On |
That might be a decent middle ground (somewhat ugly still since we're stuck with a useless trait method, but allowing to avoid some breakage I guess). If that's the preferred way, then why would int implementations panic and not return Err instead? Also (just thinking aloud), if returning an unconditional Err is now completely valid, why wouldn't it be a default implementation with some default assoc type as well? |
We're just forwarding to the inherent methods from the standard library. We could pre-check the radix for an error ourselves, but that still has to fit into a
That would be nice, but that feature is still incomplete and unstable: rust-lang/rust#29661 |
This would allow me to implement |
@cuviper IIUC, this doc clarification/update wouldn't be considered a breaking change and thus can be done prior to 1.0 bump? |
I think it's not a breaking change, but I suppose that's debatable. I would not suggest that any existing But my earlier point was that 1.0 would not have any breaking changes either, just reflect the unchanging status quo. |
Related: #178 (comment)
Quoting
num-traits
(this comment itself is super-old),The problem:
Num
requires implementingfrom_str_radix
and tons of other traits in this crate requireNum
. So, e.g., to be able to make useSigned
, you are blocked by having to implementfrom_str_radix
, whether you want it or not. Implementing it properly for a user-defined number type (e.g. a fixed decimal) is a non-trivial task, especially given that it won't actually be used - in most cases it would be simply a waste of time.This method is not used anywhere in the crate and it's likely it's not used by anyone anywhere at all, simply because better options exist, and the provided implementation suffers from rounding errors.
If
from_str_radix()
is dropped fromNum
:Num
becomes implementable for various user-defined number types; as of right now, it's inaccessible because of that methodNum
no longer has any methods or associated types whatsoever, it becomes a neat marker trait with some supertraitsSigned
become unlocked for user-defined number types as wellRelated thread on internals re: why
std::num::from_str_radix
is (was) bad. IfFromStrRadix
was dropped from standard library, why can't it be dropped from here as well?Finally, if the current implementation has to be retained somewhere, one could move it into a new
FromStrRadix
trait.The text was updated successfully, but these errors were encountered: