Giter VIP home page Giter VIP logo

Comments (5)

Gankra avatar Gankra commented on August 22, 2024

CC me (need to think about this a bit more...)

from compare.

bluss avatar bluss commented on August 22, 2024

I've only looked at this crate for a very short while. How to handle the .get<Q: ?Sized>() model that maps have?

Without a type parameter on Natural, at least it is fine to use with both Compare<K> and Compare<Q>

I tried the following, which fails because the default comparator is C = Natural<K> so the restriction C: Compare<Q> forces K == Q :(

    pub fn contains<Q: ?Sized>(&self, key: &Q) -> bool
        where K: Borrow<Q>,
              C: Compare<Q>,
    {

With this said, I think for this use case a phantom-type based approach works better. Custom closure comparators can't cope with the Q vs K scheme anyway.

from compare.

Gankra avatar Gankra commented on August 22, 2024

This is super out of cache but I think the Borrow adaptor is supposed to be for that...?

https://github.com/contain-rs/compare/blob/master/src/lib.rs#L215-L234

from compare.

bluss avatar bluss commented on August 22, 2024

aha thanks!

from compare.

bluss avatar bluss commented on August 22, 2024

Hm I can't figure out how to use it. I don't think I can, if I require my Bmap<K, V, C> to have a C: Compare<K>, then that can't be converted in any way into something that can compare two borrowed Q values (where K: Borrow<Q>).

from compare.

Related Issues (9)

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.