Comments (3)
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.
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 somethingset_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.
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)
- Add design notes HOT 1
- Document attributes HOT 4
- bitfield should create constructor methods HOT 3
- Use the :vis fragment specifier HOT 3
- `into` should affect the setter
- Make getters work with immutable Data HOT 1
- About endianness HOT 2
- Please document the `index: usize` and `value: $from` arguments that getters and setters require HOT 4
- Unable to "Debug" for types that are backed by an array >32bytes HOT 5
- Requires AsMut and AsRef with buffers > 32 bytes HOT 2
- Trying to use it for my library but cannot compile. HOT 2
- How to properly embedded bitfield structure inside other one?
- Is there any difference between master and tagged version? HOT 6
- Support `defmt` HOT 3
- attempt to shift right with overflow' HOT 1
- Feature request: Fields constructed of multiple ranges of bits HOT 4
- Feature request: Right-padded fields
- Generate masks for the fields HOT 3
- `const fn` getters HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-bitfield.