Skip to content

Commit 62ab920

Browse files
committed
format
1 parent e94fc7b commit 62ab920

File tree

1 file changed

+42
-45
lines changed

1 file changed

+42
-45
lines changed

src/generate/register.rs

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ pub fn render(
163163
mod_items.extend(w_impl_items);
164164

165165
mod_items.extend(quote! {
166-
#[doc = "Writes raw bits to the register."]
167-
pub unsafe fn bits(&mut self, bits: #rty) -> &mut Self {
168-
self.0.bits(bits);
169-
self
170-
}
166+
#[doc = "Writes raw bits to the register."]
167+
pub unsafe fn bits(&mut self, bits: #rty) -> &mut Self {
168+
self.0.bits(bits);
169+
self
170+
}
171171
});
172172

173173
close.to_tokens(&mut mod_items);
@@ -465,35 +465,34 @@ pub fn fields(
465465

466466
if has_reserved_variant {
467467
arms.extend(quote! {
468-
i => Res(i),
469-
});
468+
i => Res(i),
469+
});
470470
} else if 1 << width.to_ty_width()? != variants.len() {
471471
arms.extend(quote! {
472-
_ => unreachable!(),
473-
});
472+
_ => unreachable!(),
473+
});
474474
}
475475

476476
if has_reserved_variant {
477477
enum_items.extend(quote! {
478-
///Get enumerated values variant
479-
#inline
480-
pub fn variant(&self) -> crate::Variant<#fty, #name_pc_a> {
481-
use crate::Variant::*;
482-
match self.bits {
483-
#arms
484-
}
485-
}
486-
});
478+
///Get enumerated values variant
479+
#inline
480+
pub fn variant(&self) -> crate::Variant<#fty, #name_pc_a> {
481+
use crate::Variant::*;
482+
match self.bits {
483+
#arms
484+
}
485+
}
486+
});
487487
} else {
488488
enum_items.extend(quote! {
489489
///Get enumerated values variant
490490
#inline
491491
pub fn variant(&self) -> #name_pc_a {
492-
match self.bits {
493-
#arms
494-
}
495-
}
496-
});
492+
match self.bits {
493+
#arms
494+
}
495+
}});
497496
}
498497

499498
for v in &variants {
@@ -511,12 +510,12 @@ pub fn fields(
511510

512511
let doc = format!("Checks if the value of the field is `{}`", pc);
513512
enum_items.extend(quote! {
514-
#[doc = #doc]
515-
#inline
516-
pub fn #is_variant(&self) -> bool {
517-
**self == #name_pc_a::#pc
518-
}
519-
});
513+
#[doc = #doc]
514+
#inline
515+
pub fn #is_variant(&self) -> bool {
516+
**self == #name_pc_a::#pc
517+
}
518+
});
520519
}
521520
}
522521

@@ -595,21 +594,19 @@ pub fn fields(
595594
if !variants.is_empty() {
596595
if unsafety.is_some() {
597596
proxy_items.extend(quote! {
598-
///Writes `variant` to the field
599-
#inline
600-
pub fn variant(self, variant: #name_pc_aw) -> &'a mut W {
601-
unsafe {
602-
self.#bits(variant.into())
597+
///Writes `variant` to the field
598+
#inline
599+
pub fn variant(self, variant: #name_pc_aw) -> &'a mut W {
600+
unsafe { self.#bits(variant.into()) }
603601
}
604-
}
605602
});
606603
} else {
607604
proxy_items.extend(quote! {
608-
///Writes `variant` to the field
609-
#inline
610-
pub fn variant(self, variant: #name_pc_aw) -> &'a mut W {
611-
self.#bits(variant.into())
612-
}
605+
///Writes `variant` to the field
606+
#inline
607+
pub fn variant(self, variant: #name_pc_aw) -> &'a mut W {
608+
self.#bits(variant.into())
609+
}
613610
});
614611
}
615612

@@ -619,11 +616,11 @@ pub fn fields(
619616

620617
let doc = util::escape_brackets(util::respace(&v.doc).as_ref());
621618
proxy_items.extend(quote! {
622-
#[doc = #doc]
623-
#inline
624-
pub fn #sc(self) -> &'a mut W {
625-
self.variant(#name_pc_aw::#pc)
626-
}
619+
#[doc = #doc]
620+
#inline
621+
pub fn #sc(self) -> &'a mut W {
622+
self.variant(#name_pc_aw::#pc)
623+
}
627624
});
628625
}
629626
}

0 commit comments

Comments
 (0)