GithubHelp home page GithubHelp logo

Comments (3)

dzamlo avatar dzamlo commented on August 23, 2024

The BitRange trait was never really intended to be used as-is. The goal of this trait is the method can be called from the code generated by the macro, not by a developer. That explain the" quite a weird API".

But adding such a method would be quite simple. The hardest thing will be finding a name for this methods. Any suggestions ?

from rust-bitfield.

rnestler avatar rnestler commented on August 23, 2024

The goal of this trait is the method can be called from the code generated by the macro, not by a developer.

So I'm using bitfield wrong / not as intended? Is there something already existing I could use instead?

But adding such a method would be quite simple. The hardest thing will be finding a name for this methods. Any suggestions?

Finding a good name is indeed hard here.

A few ideas:

  • insert_bits(bit_index, number_of_bits, value) Makes it clear that we insert a number of bits at a position. But may wrongly imply that we shift stuff around or something
  • set_bits_at(bit_index, number_of_bits, value)
  • append_bit_range(bit_index, number_of_bits, value) Maybe less confusing than insert?
  • set_bit_range_at(bit_index, number_of_bits, value) Similar name to the existing one.

Also maybe there is a better name than bit_index?

from rust-bitfield.

dzamlo avatar dzamlo commented on August 23, 2024

So I'm using bitfield wrong / not as intended?

The intended use of this crates is really to use the bitfield! macro with defined fields, and then you access the fields with the generated methods.

The current implementation of BitRange (and now BitRangeMut on master) is quite naive and is only fast when LLVM can do a good job. This depends heavily on the fact that the parameters are constant, last time I tested.

I didn't try it, but bitvec maybe more appropriate for your use case.

But if you find that this crates works better for you and adding that method is useful for you, I can do that.

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.