Skip to content

Commit db5f83d

Browse files
author
Jorge Aparicio
committed
rustfmt
1 parent 2947604 commit db5f83d

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/lib.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,9 @@ pub fn gen_peripheral(p: &Peripheral, d: &Defaults) -> Vec<Tokens> {
313313
}
314314

315315
let comment = &format!("0x{:02x} - {}",
316-
register.offset,
317-
respace(&register.info.description))[..];
316+
register.offset,
317+
respace(&register.info
318+
.description))[..];
318319

319320
let reg_ty = match register.ty {
320321
Either::Left(ref ty) => Ident::from(&**ty),
@@ -327,7 +328,8 @@ pub fn gen_peripheral(p: &Peripheral, d: &Defaults) -> Vec<Tokens> {
327328
});
328329

329330
offset = register.offset +
330-
register.info.size
331+
register.info
332+
.size
331333
.or(d.size)
332334
.expect(&format!("{:#?} has no `size` field", register.info)) /
333335
8;
@@ -400,9 +402,14 @@ fn expand(registers: &[Register]) -> Vec<ExpandedRegister> {
400402

401403
let ty = Rc::new(ty.to_pascal_case());
402404

403-
let indices = array_info.dim_index.as_ref().map(|v| Cow::from(&**v)).unwrap_or_else(|| {
404-
Cow::from((0..array_info.dim).map(|i| i.to_string()).collect::<Vec<_>>())
405-
});
405+
let indices = array_info.dim_index
406+
.as_ref()
407+
.map(|v| Cow::from(&**v))
408+
.unwrap_or_else(|| {
409+
Cow::from((0..array_info.dim)
410+
.map(|i| i.to_string())
411+
.collect::<Vec<_>>())
412+
});
406413

407414
for (idx, i) in indices.iter().zip(0..) {
408415
let name = if has_brackets {
@@ -411,7 +418,8 @@ fn expand(registers: &[Register]) -> Vec<ExpandedRegister> {
411418
info.name.replace("%s", idx)
412419
};
413420

414-
let offset = info.address_offset + i * array_info.dim_increment;
421+
let offset = info.address_offset +
422+
i * array_info.dim_increment;
415423

416424
out.push(ExpandedRegister {
417425
info: info,
@@ -432,10 +440,12 @@ fn expand(registers: &[Register]) -> Vec<ExpandedRegister> {
432440
fn type_of(r: &Register) -> String {
433441
let ty = match *r {
434442
Register::Single(ref info) => Cow::from(&*info.name),
435-
Register::Array(ref info, _) => if info.name.contains("[%s]") {
436-
info.name.replace("[%s]", "").into()
437-
} else {
438-
info.name.replace("%s", "").into()
443+
Register::Array(ref info, _) => {
444+
if info.name.contains("[%s]") {
445+
info.name.replace("[%s]", "").into()
446+
} else {
447+
info.name.replace("%s", "").into()
448+
}
439449
}
440450
};
441451

0 commit comments

Comments
 (0)