Code Monkey home page Code Monkey logo

Comments (6)

SimonSapin avatar SimonSapin commented on July 24, 2024

I don’t think it makes sense to consider an URL intrinsically "greater" or "lesser" than another. But what’s the use case?

from rust-url.

alexcrichton avatar alexcrichton commented on July 24, 2024

The need for this is derived from Cargo, which primarily uses it for deterministic output in a few locations. There are spots where we sort an array of PackageId (which transitively contains a Url at some point) to ensure that the output is consistent among stages. Put another way, the order itself isn't super important so long as it's consistent.

I personally view core traits like this as being useful to define on core types like Url, even when they don't always make 100% sense (e.g. PartialEq for RefCell)

from rust-url.

SimonSapin avatar SimonSapin commented on July 24, 2024

Ok, that sounds like a real use case and I don’t have better way to solve it. I still don’t think any ordering is meaningful for URLs, but adding a few #[derive(PartialOrd)] is not harmful either.

I don’t get your second point, though. What qualifies as a core trait? Should Url implement Add, for example? What qualifies as a core type? What makes Url more "core" than, say, cssparser::RGBA? As to RefCell, since it’s a container it doesn’t need to have a meaningful equality by itself, it just defers to its contents.

from rust-url.

alexcrichton avatar alexcrichton commented on July 24, 2024

Ah I just mean "core" in the sense that it's often a building block for many other types. For example there are probably going to be a lot of structs which store a Url, some of which may want to have some sort of ordering eventually.

from rust-url.

seanmonstar avatar seanmonstar commented on July 24, 2024

As for whether Ordering makes sense for Url: it seems natural that it would
be the same as Ord for strings: likely alphabetically.

On Mon, Jun 1, 2015, 11:08 AM Alex Crichton [email protected]
wrote:

Ah I just mean "core" in the sense that it's often a building block for
many other types. For example there are probably going to be a lot of
structs which store a Url, some of which may want to have some sort of
ordering eventually.


Reply to this email directly or view it on GitHub
#114 (comment).

from rust-url.

SimonSapin avatar SimonSapin commented on July 24, 2024

Ordering URLs by the string ordering of their serialization seems reasonable, but it’s not the same ordering as what #[derive(PartialOrd)] would get us with the current internal representation. Still, we should probably stick with derive, to avoid performance issues like #113.

from rust-url.

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.