Code Monkey home page Code Monkey logo

Comments (5)

gsingh93 avatar gsingh93 commented on May 28, 2024

Can a core team member comment on this? It's an easy change to make, and it can have huge benefits. I was thinking of changing all the std::ops traits to take a type that implements ToBigInt, so that you can do useful things like adding regular integer constants to BigInts, which would greatly reduce the verbosity of the current API. However, I can't do this because these conversion methods can fail.

from num.

gsingh93 avatar gsingh93 commented on May 28, 2024

@huonw, @alexcrichton, do you have thoughts on this? I'd like to implement it.

from num.

gsingh93 avatar gsingh93 commented on May 28, 2024

@hauleth and @cuviper, you are the new maintainers, correct? What do you think about this issue?

from num.

cuviper avatar cuviper commented on May 28, 2024

I'd rather use From for infallible conversions (#117) and leave these alone. You already pointed out that ToBigUint could fail on signed values, and even ToBigInt could fail if it were implemented for something like BigRational. I think it's useful to allow this possibility, and we don't need to break the current API when From and Into can do the job you want.

Expanding generic std::ops for From/Into types sounds fine, but do note the issues that came up in #125 doing something like this for Complex. You can be generic on the RHS, but the compiler won't let you implement for T on the LHS.

from num.

cuviper avatar cuviper commented on May 28, 2024

FYI, num-bigint has its own repo now: https://github.com/rust-num/num-bigint

But I think my prior comment still stands, and we do have From primitive integers now.

from num.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.