Skip to content

Commit bbd3a79

Browse files
bors[bot]burrbull
andauthored
Merge #594
594: clean FieldReader r=Emilgardis a=burrbull Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
2 parents 1882951 + b0d3eed commit bbd3a79

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
- Clean `FieldReader`
1011
- Optional PascalCase for Enum values instead of UPPER_CASE
1112

1213
## [v0.22.2] - 2022-04-13

src/generate/generic.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,11 @@ impl<REG: RegisterSpec> W<REG> {
226226
/// Field reader.
227227
///
228228
/// Result of the `read` methods of fields.
229-
pub struct FieldReader<U, T> {
229+
pub struct FieldReader<U> {
230230
pub(crate) bits: U,
231-
_reg: marker::PhantomData<T>,
232231
}
233232

234-
impl<U, T> FieldReader<U, T>
233+
impl<U> FieldReader<U>
235234
where
236235
U: Copy,
237236
{
@@ -241,7 +240,6 @@ where
241240
pub(crate) fn new(bits: U) -> Self {
242241
Self {
243242
bits,
244-
_reg: marker::PhantomData,
245243
}
246244
}
247245

@@ -252,18 +250,18 @@ where
252250
}
253251
}
254252

255-
impl<U, T, FI> PartialEq<FI> for FieldReader<U, T>
253+
impl<U, T> PartialEq<T> for FieldReader<U>
256254
where
257255
U: PartialEq,
258-
FI: Copy + Into<U>,
256+
T: Copy + Into<U>,
259257
{
260258
#[inline(always)]
261-
fn eq(&self, other: &FI) -> bool {
259+
fn eq(&self, other: &T) -> bool {
262260
self.bits.eq(&(*other).into())
263261
}
264262
}
265263

266-
impl<FI> FieldReader<bool, FI> {
264+
impl FieldReader<bool> {
267265
/// Value of the field as raw bits.
268266
#[inline(always)]
269267
pub fn bit(&self) -> bool {

src/generate/register.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ pub fn fields(
559559

560560
mod_items.extend(quote! {
561561
#[doc = #readerdoc]
562-
pub struct #name_pc_r(crate::FieldReader<#fty, #name_pc_a>);
562+
pub struct #name_pc_r(crate::FieldReader<#fty>);
563563

564564
impl #name_pc_r {
565565
#[inline(always)]
@@ -570,7 +570,7 @@ pub fn fields(
570570
}
571571

572572
impl core::ops::Deref for #name_pc_r {
573-
type Target = crate::FieldReader<#fty, #name_pc_a>;
573+
type Target = crate::FieldReader<#fty>;
574574

575575
#[inline(always)]
576576
fn deref(&self) -> &Self::Target {
@@ -582,7 +582,7 @@ pub fn fields(
582582
} else {
583583
mod_items.extend(quote! {
584584
#[doc = #readerdoc]
585-
pub struct #name_pc_r(crate::FieldReader<#fty, #fty>);
585+
pub struct #name_pc_r(crate::FieldReader<#fty>);
586586

587587
impl #name_pc_r {
588588
#[inline(always)]
@@ -592,7 +592,7 @@ pub fn fields(
592592
}
593593

594594
impl core::ops::Deref for #name_pc_r {
595-
type Target = crate::FieldReader<#fty, #fty>;
595+
type Target = crate::FieldReader<#fty>;
596596

597597
#[inline(always)]
598598
fn deref(&self) -> &Self::Target {

0 commit comments

Comments
 (0)