Comments (4)
It's definitely a breaking change for external implementors, as you mention. The new trait would have to stand alone. But I'd guess that's not so bad since implementors wouldn't have to do both, just the one most appropriate to them.
from num-traits.
I figure that the plan could be to add that new RealNum
trait without touching Float
, by copy-pasting appropriate items, then adding impl<T: Float> RealNum for T { /* trivial impls here */ }
so that RealNum
is useful to everyone right away.
Somewhere in there we'd leave a note saying "in the next major version increase, let's make Float require RealNum, and remove intersecting items." (or not - it's not mandatory)
I would be interested in doing a PR that does this, if you're OK with that. If not, it's fine too!
For now, people that really need it can make their fixed-point types implement Float
's items, but use unimplemented!{}
on those that are floating-point-specific - then, they only have to make sure these items are never used.
Alternatively, they can implement these items "incorrectly" but in a way that doesn't panic.
from num-traits.
So the problem is, that when splitting hierarchy, the implementors of Float will now additionaly have to implement RealNum, isn't it?
I don't think, anyone would implement Float, because it's only suited for floats like the built in types.
Maybe it's used for wrapper types.
Maybe it would be useful to be able to implement functions of supertraits in subtraits. This should then solve the current problem.
Is it worth thinking about an RFC for such a feature?
from num-traits.
So the problem is, that when splitting hierarchy, the implementors of Float will now additionaly have to implement RealNum, isn't it?
I don't think, anyone would implement Float, because it's only suited for floats like the built in types.
Maybe it's used for wrapper types.
Exactly -- for example, one such wrapper that I know of is NoisyFloat
.
Maybe it would be useful to be able to implement functions of supertraits in subtraits. This should then solve the current problem.
Is it worth thinking about an RFC for such a feature?
You mean as a new language feature? I'm not sure if this is a frequent enough scenario to warrant that, but it doesn't hurt to propose the idea. Maybe start as a pre-RFC on the internals forum.
from num-traits.
Related Issues (20)
- Exclusively increasing? HOT 3
- Why not `checked_pow` as a trait method HOT 1
- Officially deprecate `Saturating` HOT 2
- [feature request] total_cmp for num_traits::Float HOT 8
- Documentation should state the purpose of the num-traits crate
- Num::FromStrRadixErr should implement Debug HOT 2
- Does not compiles with target-feature=-sse2 HOT 3
- Add minimal permissions to GitHub workflows HOT 6
- Forgotten function in `Float`: `is_subnormal`! HOT 1
- [question] Is `num_traits::cast::<f64, f32>(f64) -> Option<f32>` just `f64 as f32`? So it never returns `None`. HOT 4
- Add a security policy
- Why does Zero::zero not take self? HOT 11
- Check if `PrimInt` is even or not HOT 3
- `CheckedAdd` should probably not extend `Add` HOT 3
- Why not make zero() and one() as const functions? HOT 2
- Add trigonometry functions HOT 1
- constifying traits in an nighlty branch or feature gate it? (with #[const_trait]) HOT 2
- `cargo doc` fails if they run it with nightly Rust HOT 2
- New nightly version broke `cargo-doc`, unintended use of unstable feature HOT 3
- Is there any hope of seeing a minor release anytime soon? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from num-traits.