Comments (7)
I think std::convert::From
is the right trait for lossless conversions. But we can't implement that in num
except for our own types, like for BigInt
/BigUint
in #117. Maybe you should propose adding primitive From
impls in rust proper?
from num.
BTW, nice graph!
You might simplify it a bit by leaving it implicit for transitive conversions. That is, if A->B and B->C, then implicitly A->C. Hmm, I wonder if a generic impl can express that, something like:
impl<A, B: From<A>, C: From<B>> From<A> for C {
fn from(a: A) -> C { C::from(B::from(a)) }
}
But the existence of impl<T> From<T> for T
might make this explode...
(don't mind me, just musing...)
from num.
Maybe the conv crate covers this appropriately now.
from num.
Does conv
have any new infallible conversions? I only see ConvUtil::into_as
which is using the standard Into
trait anyway.
But I noticed nightly From
does now document integer upcasts -- this was merged only 2 days ago in rust-lang/rust#28921! So if you submit a similar addition for floats, you'll be done here. (If you don't want to, let me know and maybe I'll try it.)
from num.
Nice! I had missed that. Please do if you want to!
from num.
The float conversions are now merged! I think there's nothing else to do here.
from num.
Nice!
from num.
Related Issues (20)
- Blanket implementation of Signed for &T HOT 2
- Iterating over a range of floats produces discrepancies HOT 2
- As (truncating) conversion for BigInt? HOT 5
- `T::zero()`, `T::one()`, etc should be const fn HOT 2
- Add a function that actually does `abs_sub` for both Signed and Unsign numbers.
- Traits for converting from/into bytes HOT 1
- Implement rand traits for Ratio ? HOT 2
- Conversion between openssl::bn::BigNum and num::BigInt HOT 4
- Question: Is this crate official? HOT 3
- Support a more generic binomial coefficients
- Trait size of number in bits
- Human readable (concise) output HOT 1
- Signed::is_positive and Signed::is_negative implementation/documentation is inconsistent
- Extended GCD on BigUint doesn't work HOT 2
- Yank pre-Rust 1.0.0 versions HOT 1
- Bump num-family to v1.0? HOT 6
- conversion from BigUint to Complex and vice versa HOT 1
- `rustc-serialize` is deprecated, uses deprecated Rust features HOT 2
- Invalid Complex formatting for floats (f32 and f64). HOT 3
- New API additions in num-complex 0.4.2 not configurable through num version HOT 2
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.