Comments (4)
Hi @scott-wilson, thank you for your feedback and for the suggestion!
Yes, indeed, we don't have support for "1/2", although that feels rather trivial to split in two integers and, perhaps, might even use Rust own built-in string to integer parsing capabilities.
Nonetheless, it might be nice to have a shortcut for that in the library API, especially that it is the format we produce via Display. If you have an interest in providing a PR for that, that would be appreciated!
using nom for parsing the string
Yes, nom is a powerful tool. We only have rather trivial parsing in this crate, so I don't feel a strong need to use it, but if you provided the implementation in your PRs, that would be nice (ideally a separate PR with refactoring and a separate one for parsing "1/2"). For the refactored code I would appreciate having a benchmark as well, to make sure we don't have a performance regression.
from fraction.
Sounds good. I'll take a crack at it and see how it benchmarks.
from fraction.
Thank you for the contribution!
Released in 0.10.0
.
P.S.
Regarding refactoring that with nom
it feels like it might not be worth pulling nom to only cover our existing parsing needs. Having nom as a hard dependency could cause version conflicts with external projects' own nom.
Feels like maybe the benefits won't outweigh the downsides in that case.
Closing this issue for now, but please reopen if you'd like to keep that discussion going :)
from fraction.
Yeah, I feel like you're right. Thanks for the merge!
from fraction.
Related Issues (20)
- Why not implement num_traits::Real instead? HOT 3
- Overflow with small number of multiplication HOT 8
- Using `calc_precision` on `1 / 3` does not terminate HOT 4
- Initialization of Decimal without str? HOT 8
- Why no `fraction::Decimal::default()` ? HOT 2
- no-std support HOT 1
- `divide_to_string` panics on negative dividend HOT 2
- Upgrade postgresql support to 0.18.x
- How to convert to `f32` and `f64` numeric types HOT 1
- .pow() and .root() functions for fraction types HOT 3
- Serde support? HOT 2
- Fraction::from_str can fail with overflow if fractional part ends with too many zeroes HOT 3
- Weird huge values when getting the denominator of a fraction HOT 9
- Serialization support for DynaInt HOT 1
- Error: trait bounds other than `Sized` on const fn parameters are unstable HOT 2
- What does it mean that a value cannot be represented by `Ratio<T>`? HOT 2
- Fraction ceil and floor round negative fraction "the wrong way" HOT 1
- how do you conver a GenericFraction into a float? HOT 5
- Is there a list of methods that floats have that aren't impled for fractions 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 fraction.