Skip to content

Commit a4f9ad8

Browse files
committed
📝 Update readme accordingly
1 parent 9731ce5 commit a4f9ad8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ struct MyBitfield {
9797
/// sign extend for signed integers
9898
#[bits(13)]
9999
negative: i16,
100-
/// supports any type, with `into`/`from` expressions (that are const eval)
100+
/// supports any type, with `into_bits`/`from_bits` (const) functions,
101+
/// if not configured otherwise with the `into`/`from` parameters of the bits attribute.
101102
///
102-
/// the field is initialized with 0 (passed into `from`) if not specified otherwise
103-
#[bits(16, into = this as _, from = CustomEnum::from_bits(this))]
103+
/// the field is initialized with 0 (passed into `from_bits`) if not specified otherwise
104+
#[bits(16)]
104105
custom: CustomEnum,
105106
/// public field -> public accessor functions
106107
#[bits(12)]
@@ -119,7 +120,10 @@ enum CustomEnum {
119120
C = 2,
120121
}
121122
impl CustomEnum {
122-
// This has to be const eval
123+
// This has to be a const fn
124+
const fn into_bits(self) -> u64 {
125+
self as _
126+
}
123127
const fn from_bits(value: u64) -> Self {
124128
match value {
125129
0 => Self::A,

0 commit comments

Comments
 (0)