GithubHelp home page GithubHelp logo

`const fn` getters about rust-bitfield HOT 2 OPEN

Apanatshka avatar Apanatshka commented on August 23, 2024
`const fn` getters

from rust-bitfield.

Comments (2)

dzamlo avatar dzamlo commented on August 23, 2024

I wasn't able to generate const fn getters because the getter call a method from the (internal) BitRange trait which is not const. I tried to make it const but it seems to not be possible to make a method from a trait const (see rustc --explain E0379).

If you find a satisfying workaround that doesn't imply getting rid of the trait, I would be happy to implement it.

from rust-bitfield.

Apanatshka avatar Apanatshka commented on August 23, 2024

I read up on that explanation and the linked RFC. Looks like const traits aren't a thing (yet?). All I can think of to do is to generate your current BitRange implementations as loose pub const fns, generate the BitRange implementations to use those, and have the exposed macro's of bitfield use the const version so they can be const themselves. Then the users of the crate can choose between the const functions and the more convenient trait abstraction.

from rust-bitfield.

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.