Giter Club home page Giter Club logo

Comments (10)

phil-opp avatar phil-opp commented on July 17, 2024 2

I think it should be possible to move the DEBUG_STR constant to a separate, private trait. Looking into it right now.

from x86_64.

phil-opp avatar phil-opp commented on July 17, 2024 2

Yes it does, at least in the current implementation. Maybe it's possible to avoid this somehow, but it's probably not worth the trouble. So exposing DEBUG_STR is probably the better solution.

from x86_64.

phil-opp avatar phil-opp commented on July 17, 2024 1

Thanks for reporting! I definitely see that this is confusing.

I am not sure if this is actually a rustc issue or not.

See rust-lang/rust#67105 and rust-lang/rust#83882. It looks like the is no consensus on what should be the expected behavior yet (forbid access in generic code or allow access in non-generic code too).

from x86_64.

phil-opp avatar phil-opp commented on July 17, 2024 1

Yes, but in that case we should probably redefine the DEBUG_STR constant in the respective child traits. Otherwise it's not included in the docs and only accessible using generics.

from x86_64.

Freax13 avatar Freax13 commented on July 17, 2024 1

pub trait Mapper<S: PageSize + DebugOutput> {

This makes it impossible for users to add their own generic implementations because they can't name DebugOutput, doesn't it?

Isn't that what you meant with #404 anyway?

Users should never implement this trait themselves. [...]

#404 is meant to prevent users from implementing PageSize on their own types. What I meant with my comment was that with the changes in a5585ef, it would be impossible for users to create generic implementations of Mapper<S>.

from x86_64.

Freax13 avatar Freax13 commented on July 17, 2024

I can't think of a good way to prevent this, other than by making the Sealed trait private. Unfortunately, private supertraits are only allowed starting with Rust 1.74 following RFC 2145. Our current MSRV is 1.59, so that's not an option.

from x86_64.

phil-opp avatar phil-opp commented on July 17, 2024

It kind of works, but it leads to a lot of additional bounds on the new private trait: a5585ef . I don't think that this is an improvement...

from x86_64.

mkroening avatar mkroening commented on July 17, 2024

I guess the alternative would be to commit to having this part of the public API even though that was not what we wanted in #404, right?

from x86_64.

Freax13 avatar Freax13 commented on July 17, 2024

pub trait Mapper<S: PageSize + DebugOutput> {

This makes it impossible for users to add their own generic implementations because they can't name DebugOutput, doesn't it?

from x86_64.

mkroening avatar mkroening commented on July 17, 2024

pub trait Mapper<S: PageSize + DebugOutput> {

This makes it impossible for users to add their own generic implementations because they can't name DebugOutput, doesn't it?

Isn't that what you meant with #404 anyway?

Users should never implement this trait themselves. [...]

from x86_64.

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.