Skip to content

Commit 1209652

Browse files
authored
chore: bit setter and clearer return mutable references to Self (#112)
* chore: bit setter and clearer return mutable references to `Self` * chore: add a changelog
1 parent 4ee7fb7 commit 1209652

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### Changed
88
- `set_xxx(true_or_false)` methods of the Registers and the Extended Capabilities are split into `set_xxx()` and `clear_xxx()`.
99
- `CapabilityParameters1::max_primary_stream_array_size` is renamed to `CapabilityParameters1::maximum_primary_stream_array_size`.
10+
- Bit setter and clearer now return mutable references to `Self`.
1011

1112
## 0.6.0 - 2021-04-27
1213
### Added

src/macros.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,19 @@ macro_rules! bit_modifier {
3131
#[doc = "Sets the"]
3232
#[doc = $name]
3333
#[doc = "bit."]
34-
pub fn [<set_ $method>](&mut self){
34+
pub fn [<set_ $method>](&mut self)->&mut Self{
3535
use bit_field::BitField;
3636
self.0.set_bit($bit,true);
37+
self
3738
}
3839

3940
#[doc = "Clears the"]
4041
#[doc = $name]
4142
#[doc = "bit."]
42-
pub fn [<clear_ $method>](&mut self){
43+
pub fn [<clear_ $method>](&mut self)->&mut Self{
4344
use bit_field::BitField;
4445
self.0.set_bit($bit,false);
46+
self
4547
}
4648
}
4749
};
@@ -73,9 +75,10 @@ macro_rules! rw1c_bit {
7375
#[doc = "Clears the"]
7476
#[doc = $name]
7577
#[doc = "bit."]
76-
pub fn [<clear_ $method>](&mut self){
78+
pub fn [<clear_ $method>](&mut self)->&mut Self{
7779
use bit_field::BitField;
7880
self.0.set_bit($bit,true);
81+
self
7982
}
8083
}
8184
};
@@ -87,9 +90,10 @@ macro_rules! w1s_bit {
8790
#[doc = "Sets the"]
8891
#[doc = $name]
8992
#[doc = "bit."]
90-
pub fn [<set_ $method>](&mut self){
93+
pub fn [<set_ $method>](&mut self)->&mut Self{
9194
use bit_field::BitField;
9295
self.0.set_bit($bit,true);
96+
self
9397
}
9498
}
9599
};

0 commit comments

Comments
 (0)