Comments (2)
To simplify the overall design of this crate we should actually replace the current #[bitfield(filled: bool)]
parameter with the proposed #[bitfield(bits = N)]
parameter.
They way bits = N
could replace filled: bool
is wherever filled = false
has to be used right now we would enforce usage of bits = N
with N
being the bits that the user wants the bitfield to have. With #[skip] __: BN
users can easily define whole areas of a bitfield to leave as undefined which should be used instead of using filled = false
and is more powerful than that.
This also unifies design of the #[derive(BitfieldSpecifier)]
derive macro for enums.
from modular-bitfield.
I have made some more thoughts about this and came to the conclusion that with the introduction of a bits: int
parameter we no longer really want or need the bytes: int
parameter with which we (so far) controlled the amount of bytes that a bitfield is going to need. So introducing the bits: int
should deprecate or remove the bytes: int
parameter which makes the overall design a bit simpler because you no longer need to handle cases like bits = 32, bytes = 3
that are conflicting with each other.
What I wrote above about filled: bool
parameter might not be true entirely. There are two stand points:
-
Keeping
filled: bool
and allowing interactions using both configs.bits = N, filled = true
: The bitfield must not have undefined bits and must have a bit width of exactlyN
.bits = N, filled = false
: The bitfield may have undefined bits and defaults to bit width equal toN
. It is asserted at compile time that the required bits do not exceed or equalN
- aka it is asserted that there are undefined bits.
-
Removing of the
filled: bool
parameter:- How exactly can be differentiate between the 2 above cases with
filled = false
andfilled = true
?
Do we actually really needfilled = false
? We just introduced#[skip] __: BN
for pretty much the same purpose.
The only advantage offilled = false
is that it is a tad less to write and does not require yet another "fill" field.
This comes more in handy if the bitfield is generally very small, e.g. contains just 1 or 2 bit fields.
- How exactly can be differentiate between the 2 above cases with
from modular-bitfield.
Related Issues (20)
- Support for `to_u32()` conversion to `u32` and similar
- #[bitfield] on empty struct causes compilation error
- Feature Request: Ability to specify default value for field
- Is this crate maintained? HOT 1
- Implement serde derives replacement HOT 2
- Feature request: Array support HOT 3
- Into<uN> and TryFrom<uN> for uN bitfields HOT 2
- `with_*` methods should have `#[must_use]` annotation HOT 2
- Help: CheckFillsUnalignedBits unsatisfied HOT 2
- Support rust union structs HOT 1
- Feature request: Allow naming fields "Bytes" HOT 1
- Question: Array of bitfields HOT 1
- #[repr(...)] for unfilled bitfields?
- Generic structs not supported HOT 7
- [Question] Polymorphic bitfileds HOT 1
- Support for byte arrays
- `#[non_exhaustive]` enum support HOT 9
- const fn support for getters (and setters if possible) HOT 1
- How to implement signed 10 bit number? HOT 8
- [Feature Request] Better Note for (Size % 8)
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 modular-bitfield.