Giter VIP home page Giter VIP logo

Comments (7)

babhishek21 avatar babhishek21 commented on June 2, 2024 1

Yup, I'm putting a bound for PartialOrd for Idx.

from a-range.

babhishek21 avatar babhishek21 commented on June 2, 2024

Looks like a good time to learn Rust. Can I work on this?

from a-range.

killercup avatar killercup commented on June 2, 2024

Absolutely! Let me know if you have any questions!

from a-range.

babhishek21 avatar babhishek21 commented on June 2, 2024

Hi! would you like me to throw explicit panics or do you have something else in mind?

from a-range.

killercup avatar killercup commented on June 2, 2024

@babhishek21 good question. I'd go with a panic for now, as it's most likely a programmer error; in teh future, we can introduce try_up_to and similar if people ask for it.

from a-range.

babhishek21 avatar babhishek21 commented on June 2, 2024

@killercup So, I was going to put in panics of the sort:

panic!("Cannot count upwards from {} to {}", self.from, x);   // `self.from` and `x` are both of generic type `Idx`

But that'd mean putting bounds for Idx to be std::fmt::Displayable (which really shouldn't be hard requirement for consumers of this crate). So how do I keep my panics descriptive enough?

from a-range.

killercup avatar killercup commented on June 2, 2024

Well, you could use debug output ({:?}) but that'd require Debug, of course. It's implemented by more types, but still a needless constraint.

I'd probably just go with a generic message like "invalid range: upper bound cannot be less than lower bound" (or reverse for… reverse).

Speaking of bounds: Seems like this also means we'll need PartialOrd to check of <=/>=. It's a bit stricter than PartialEq, but does make sense over all.

from a-range.

Related Issues (13)

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.