Git Product home page Git Product logo

Comments (2)

nical avatar nical commented on May 29, 2024

Sorry for the delay, the euclid stuff went under my radar for a while.

I agree that the behavior of contains and from_points put next to each other is confusing.
I believe that the [a..b[ behavior in contains is expected because of how it is used in servo/gecko especially with integer coordinates (Rect{ pos: (0, 0), size: (10, 10) } and Rect{ pos: (10, 0), size: (10, 10) } do not overlap).

Right now from_points is only used in webrender in a few places that don't seem to be negatively affected by the non-inclusiveness of the right and bottom edges of the rect.

With integer coordinates it would make sense that from_points inflate the size by 1 to match the semantics of contains. With floats I suppose that what would make sense is to inflate the size to the next floating point value (C/C++ nextafter which doesn't seem to exist in rust).

The generic specialization story in rust isn't great at the moment unfortunately, maybe we can paper over it with a trait that provides the next value implemented for all float and integer types.

from euclid.

rsaarelm avatar rsaarelm commented on May 29, 2024

Yeah, I ran into the float case myself when trying to generalize the helper method for this. I just went with One::one in my own program, but I wouldn't be happy putting that in euclid, and the proper solution with the nextvalue trait seems very heavyweight just for this one case. The simple thing here would be to add a note to the rustdoc of from_points that the results may be unintuitive because of the half-inclusion semantics.

from euclid.

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.