Comments (7)
I have no plans to start making breaking changes. For now, I think if you have such restricted needs, it might be better to just fork into a new crate for your environment.
from num-traits.
Features are meant to be additive. If crate A uses num-traits
with some current features and uses floats, and crate B turns on the no-float
feature, and then both are used as dependencies in some larger project, then A will be broken by B's choice. That's not acceptable.
Forking is not good option as will need fork whole crate tree built on top.
API changes also require the whole tree to adapt, and this crate has thousands of dependents.
You may be able to [patch]
in a replacement crate, but overall I'd say that your specialized/restricted needs call for specialized crates.
from num-traits.
I would be happy to PR it solution has chances to be accepted
from num-traits.
Other option is to gate all float methods behind float feature
from num-traits.
Thanks for response.
Forking is not good option as will need fork whole crate tree built on top.
Smallest breaking change can be made by making disable of floats only if no default no-floats features is defined.
So if default features are defined on some already existing, all will be as before.
Only issue would be if all-features
are used. So I doubt I saw it wide usage.
from num-traits.
Features are meant to be additive. If crate A uses num-traits with some current features and uses floats, and crate B turns on the no-float feature, and then both are used as dependencies in some larger project, then A will be broken by B's choice. That's not acceptable.
It looks very desired behavior. If somebody enables "disabling" feature, it will break all float usage in other crates, compilation will fail, which is right. Nobody to use floats.
API changes also require the whole tree to adapt, and this crate has thousands of dependents.
that is clear, anyway just tried to propose :) so need to adapt on forks or via gate(both likely).
You may be able to [patch] in a replacement crate
Patch will patch crate for all deps, so if any dep will impl float methods, they will fail to compile. So will need to patch all other crates built on top. Num based crates about fractions(ratio) and big integers(bigger than 128) are of interest.
but overall I'd say that your specialized/restricted needs call for specialized crates.
Thank you for response. I understand.
So my understanding (and usage), there are core::ops traits to be used in any context/need/vm. I just peek traits what work for me. num-traits
has a lot of good traits generic enough and I use them a lot (Zero/One/ops).
But To/FromPrimitive are not generic enough, I cannot use to integer vs float primitives. Floats leaks to compilation result as part of format/display/debug routines, which breaks specialized environments.
I can use core::ops
without touching float code, but I cannot do that with num-trait
, which would be possible num-traits
would be generic enough to be used in any context (so basically this states that breaking thousands of dependents
is right thing to do to make num-trait as generic as core::ops
). And after that num-rational
and num-big
and many other crates conforming from num-traits
will work out of box for some(my) use cases.
from num-traits.
Another possible breaking change tbh can be done accopanying any breaking change
https://docs.rs/num/latest/num/traits/trait.Zero.html
Zero
forces to have Add
which limits Zero
usage. I can have Zero
without ability to add.
One
is also useful without ability to Mul
.
Also some part of num-traits is already splits float to float
mod, so To/From primitive looks like just tech dept to split.
Closing for now so. Can send PR with gate or split of traits if any will be considered as option. In general I feel that not my specialized needs are kind of things, but that num-traits are not general enough(easy to fix, so breaking change) in the end.
from num-traits.
Related Issues (20)
- `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
- add a quotien_and_rem_euclid method to Euclid trait HOT 1
- Document and/or allow truncation/rounding when casting from float to int? HOT 4
- Feature request: OverflowingShl HOT 2
- Feature request: can we have a trait for checked_add_signed uX implementations?
- Add `BitOrAssign` etc. to `PrimInt` HOT 4
- Introduce derive macros HOT 1
- Adding {ilog, ilog2, ilog10} to PrimInt HOT 1
- Add `trait UnsignedAbs` HOT 3
- Add `round_to_digit` method to `Float` trait. HOT 2
- `struct` built on top of `pub trait Num` can't compile if `pub trait Num` doesn't impl `Debug` HOT 4
- Add `Hash` as a trait bound for `PrimInt` HOT 2
- Add is_signed 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.