Skip to content

Commit b80f8ca

Browse files
bors[bot]burrbull
andauthored
Merge #107
107: more Self r=therealprof a=burrbull Co-authored-by: Andrey Zgarbul <[email protected]>
2 parents c74f460 + e88fb96 commit b80f8ca

22 files changed

+72
-72
lines changed

src/svd/access.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ pub enum Access {
1919
}
2020

2121
impl Parse for Access {
22-
type Object = Access;
22+
type Object = Self;
2323
type Error = anyhow::Error;
2424

25-
fn parse(tree: &Element) -> Result<Access> {
25+
fn parse(tree: &Element) -> Result<Self> {
2626
let text = tree.get_text()?;
2727

2828
match &text[..] {

src/svd/addressblock.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ pub struct AddressBlock {
2121
}
2222

2323
impl Parse for AddressBlock {
24-
type Object = AddressBlock;
24+
type Object = Self;
2525
type Error = anyhow::Error;
2626

27-
fn parse(tree: &Element) -> Result<AddressBlock> {
28-
Ok(AddressBlock {
27+
fn parse(tree: &Element) -> Result<Self> {
28+
Ok(Self {
2929
offset: tree.get_child_u32("offset")?,
3030
size: tree.get_child_u32("size")?,
3131
usage: tree.get_child_text("usage")?,

src/svd/bitrange.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ pub enum BitRangeType {
3535
}
3636

3737
impl Parse for BitRange {
38-
type Object = BitRange;
38+
type Object = Self;
3939
type Error = anyhow::Error;
4040

41-
fn parse(tree: &Element) -> Result<BitRange> {
41+
fn parse(tree: &Element) -> Result<Self> {
4242
let (end, start, range_type): (u32, u32, BitRangeType) = if let Some(range) =
4343
tree.get_child("bitRange")
4444
{
@@ -113,7 +113,7 @@ impl Parse for BitRange {
113113
return Err(SVDError::InvalidBitRange(tree.clone(), InvalidBitRange::Syntax).into());
114114
};
115115

116-
Ok(BitRange {
116+
Ok(Self {
117117
offset: start,
118118
width: end - start + 1,
119119
range_type,

src/svd/cluster.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ impl Deref for Cluster {
2929
}
3030

3131
impl Parse for Cluster {
32-
type Object = Cluster;
32+
type Object = Self;
3333
type Error = anyhow::Error;
3434

35-
fn parse(tree: &Element) -> Result<Cluster> {
35+
fn parse(tree: &Element) -> Result<Self> {
3636
assert_eq!(tree.name, "cluster");
3737

3838
let info = ClusterInfo::parse(tree)?;

src/svd/clusterinfo.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ pub struct ClusterInfo {
4747
}
4848

4949
impl Parse for ClusterInfo {
50-
type Object = ClusterInfo;
50+
type Object = Self;
5151
type Error = anyhow::Error;
5252

53-
fn parse(tree: &Element) -> Result<ClusterInfo> {
53+
fn parse(tree: &Element) -> Result<Self> {
5454
let name = tree.get_child_text("name")?;
55-
ClusterInfo::_parse(tree, name.clone()).with_context(|| format!("In cluster `{}`", name))
55+
Self::_parse(tree, name.clone()).with_context(|| format!("In cluster `{}`", name))
5656
}
5757
}
5858

5959
impl ClusterInfo {
60-
fn _parse(tree: &Element, name: String) -> Result<ClusterInfo> {
61-
Ok(ClusterInfo {
60+
fn _parse(tree: &Element, name: String) -> Result<Self> {
61+
Ok(Self {
6262
name, // TODO: Handle naming of cluster
6363
derived_from: tree.attributes.get("derivedFrom").map(|s| s.to_owned()),
6464
description: tree.get_child_text_opt("description")?,

src/svd/cpu.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ pub struct Cpu {
4040
}
4141

4242
impl Parse for Cpu {
43-
type Object = Cpu;
43+
type Object = Self;
4444
type Error = anyhow::Error;
4545

46-
fn parse(tree: &Element) -> Result<Cpu> {
46+
fn parse(tree: &Element) -> Result<Self> {
4747
if tree.name != "cpu" {
4848
return Err(SVDError::NameMismatch(tree.clone()).into());
4949
}
5050

51-
Ok(Cpu {
51+
Ok(Self {
5252
name: tree.get_child_text("name")?,
5353
revision: tree.get_child_text("revision")?,
5454
endian: Endian::parse(tree.get_child_elem("endian")?)?,

src/svd/device.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ pub struct Device {
6262
}
6363

6464
impl Parse for Device {
65-
type Object = Device;
65+
type Object = Self;
6666
type Error = anyhow::Error;
6767

6868
/// Parses a SVD file
69-
fn parse(tree: &Element) -> Result<Device> {
70-
Ok(Device {
69+
fn parse(tree: &Element) -> Result<Self> {
70+
Ok(Self {
7171
name: tree.get_child_text("name")?,
7272
schema_version: tree.attributes.get("schemaVersion").cloned(),
7373
cpu: parse::optional::<Cpu>("cpu", tree)?,

src/svd/dimelement.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ pub struct DimElement {
3131
}
3232

3333
impl Parse for DimElement {
34-
type Object = DimElement;
34+
type Object = Self;
3535
type Error = anyhow::Error;
3636

37-
fn parse(tree: &Element) -> Result<DimElement> {
38-
Ok(DimElement {
37+
fn parse(tree: &Element) -> Result<Self> {
38+
Ok(Self {
3939
dim: tree.get_child_u32("dim")?,
4040
dim_increment: tree.get_child_u32("dimIncrement")?,
4141
dim_index: parse_optional::<DimIndex>("dimIndex", tree)?,

src/svd/endian.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ pub enum Endian {
2020
}
2121

2222
impl Parse for Endian {
23-
type Object = Endian;
23+
type Object = Self;
2424
type Error = anyhow::Error;
2525

26-
fn parse(tree: &Element) -> Result<Endian> {
26+
fn parse(tree: &Element) -> Result<Self> {
2727
let text = tree.get_text()?;
2828

2929
match &text[..] {

src/svd/enumeratedvalue.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ pub struct EnumeratedValue {
3838
pub(crate) _extensible: (),
3939
}
4040
impl EnumeratedValue {
41-
fn _parse(tree: &Element, name: String) -> Result<EnumeratedValue> {
42-
Ok(EnumeratedValue {
41+
fn _parse(tree: &Element, name: String) -> Result<Self> {
42+
Ok(Self {
4343
name,
4444
description: tree.get_child_text_opt("description")?,
4545
// TODO: this .ok() approach is simple, but does not expose errors parsing child objects.
@@ -51,17 +51,17 @@ impl EnumeratedValue {
5151
}
5252
}
5353
impl Parse for EnumeratedValue {
54-
type Object = EnumeratedValue;
54+
type Object = Self;
5555
type Error = anyhow::Error;
5656

57-
fn parse(tree: &Element) -> Result<EnumeratedValue> {
57+
fn parse(tree: &Element) -> Result<Self> {
5858
if tree.name != "enumeratedValue" {
5959
return Err(
6060
SVDError::NotExpectedTag(tree.clone(), "enumeratedValue".to_string()).into(),
6161
);
6262
}
6363
let name = tree.get_child_text("name")?;
64-
EnumeratedValue::_parse(tree, name.clone())
64+
Self::_parse(tree, name.clone())
6565
.with_context(|| format!("In enumerated value `{}`", name))
6666
}
6767
}

src/svd/enumeratedvalues.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ pub struct EnumeratedValues {
3939
}
4040

4141
impl Parse for EnumeratedValues {
42-
type Object = EnumeratedValues;
42+
type Object = Self;
4343
type Error = anyhow::Error;
4444

45-
fn parse(tree: &Element) -> Result<EnumeratedValues> {
45+
fn parse(tree: &Element) -> Result<Self> {
4646
assert_eq!(tree.name, "enumeratedValues");
4747
let derived_from = tree.attributes.get("derivedFrom").map(|s| s.to_owned());
4848
let is_derived = derived_from.is_some();
4949

50-
Ok(EnumeratedValues {
50+
Ok(Self {
5151
name: tree.get_child_text_opt("name")?,
5252
usage: parse::optional::<Usage>("usage", tree)?,
5353
derived_from,

src/svd/field.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ impl Deref for Field {
3030
}
3131

3232
impl Parse for Field {
33-
type Object = Field;
33+
type Object = Self;
3434
type Error = anyhow::Error;
3535

36-
fn parse(tree: &Element) -> Result<Field> {
36+
fn parse(tree: &Element) -> Result<Self> {
3737
assert_eq!(tree.name, "field");
3838

3939
let info = FieldInfo::parse(tree)?;
@@ -44,9 +44,9 @@ impl Parse for Field {
4444
if let Some(indices) = &array_info.dim_index {
4545
assert_eq!(array_info.dim as usize, indices.len())
4646
}
47-
Ok(Field::Array(info, array_info))
47+
Ok(Self::Array(info, array_info))
4848
} else {
49-
Ok(Field::Single(info))
49+
Ok(Self::Single(info))
5050
}
5151
}
5252
}

src/svd/fieldinfo.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ pub struct FieldInfo {
6161
}
6262

6363
impl Parse for FieldInfo {
64-
type Object = FieldInfo;
64+
type Object = Self;
6565
type Error = anyhow::Error;
6666

67-
fn parse(tree: &Element) -> Result<FieldInfo> {
67+
fn parse(tree: &Element) -> Result<Self> {
6868
if tree.name != "field" {
6969
return Err(SVDError::NotExpectedTag(tree.clone(), "field".to_string()).into());
7070
}
7171
let name = tree.get_child_text("name")?;
72-
FieldInfo::_parse(tree, name.clone()).with_context(|| format!("In field `{}`", name))
72+
Self::_parse(tree, name.clone()).with_context(|| format!("In field `{}`", name))
7373
}
7474
}
7575

src/svd/interrupt.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ pub struct Interrupt {
2828
}
2929

3030
impl Interrupt {
31-
fn _parse(tree: &Element, name: String) -> Result<Interrupt> {
32-
Ok(Interrupt {
31+
fn _parse(tree: &Element, name: String) -> Result<Self> {
32+
Ok(Self {
3333
name,
3434
description: tree.get_child_text_opt("description")?,
3535
value: tree.get_child_u32("value")?,
@@ -38,15 +38,15 @@ impl Interrupt {
3838
}
3939

4040
impl Parse for Interrupt {
41-
type Object = Interrupt;
41+
type Object = Self;
4242
type Error = anyhow::Error;
4343

44-
fn parse(tree: &Element) -> Result<Interrupt> {
44+
fn parse(tree: &Element) -> Result<Self> {
4545
if tree.name != "interrupt" {
4646
return Err(SVDError::NotExpectedTag(tree.clone(), "interrupt".to_string()).into());
4747
}
4848
let name = tree.get_child_text("name")?;
49-
Interrupt::_parse(tree, name.clone()).with_context(|| format!("In interrupt `{}`", name))
49+
Self::_parse(tree, name.clone()).with_context(|| format!("In interrupt `{}`", name))
5050
}
5151
}
5252

src/svd/modifiedwritevalues.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ pub enum ModifiedWriteValues {
2424
}
2525

2626
impl Parse for ModifiedWriteValues {
27-
type Object = ModifiedWriteValues;
27+
type Object = Self;
2828
type Error = anyhow::Error;
2929

30-
fn parse(tree: &Element) -> Result<ModifiedWriteValues> {
30+
fn parse(tree: &Element) -> Result<Self> {
3131
use self::ModifiedWriteValues::*;
3232
let text = tree.get_text()?;
3333

src/svd/peripheral.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,21 @@ pub struct Peripheral {
7474
}
7575

7676
impl Parse for Peripheral {
77-
type Object = Peripheral;
77+
type Object = Self;
7878
type Error = anyhow::Error;
7979

80-
fn parse(tree: &Element) -> Result<Peripheral> {
80+
fn parse(tree: &Element) -> Result<Self> {
8181
if tree.name != "peripheral" {
8282
return Err(SVDError::NotExpectedTag(tree.clone(), "peripheral".to_string()).into());
8383
}
8484
let name = tree.get_child_text("name")?;
85-
Peripheral::_parse(tree, name.clone()).with_context(|| format!("In peripheral `{}`", name))
85+
Self::_parse(tree, name.clone()).with_context(|| format!("In peripheral `{}`", name))
8686
}
8787
}
8888

8989
impl Peripheral {
90-
fn _parse(tree: &Element, name: String) -> Result<Peripheral> {
91-
Ok(Peripheral {
90+
fn _parse(tree: &Element, name: String) -> Result<Self> {
91+
Ok(Self {
9292
name,
9393
version: tree.get_child_text_opt("version")?,
9494
display_name: tree.get_child_text_opt("displayName")?,

src/svd/register.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ impl Deref for Register {
3030
}
3131

3232
impl Parse for Register {
33-
type Object = Register;
33+
type Object = Self;
3434
type Error = anyhow::Error;
3535

36-
fn parse(tree: &Element) -> Result<Register> {
36+
fn parse(tree: &Element) -> Result<Self> {
3737
assert_eq!(tree.name, "register");
3838

3939
let info = RegisterInfo::parse(tree)?;

src/svd/registercluster.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ impl From<Cluster> for RegisterCluster {
2828
}
2929

3030
impl Parse for RegisterCluster {
31-
type Object = RegisterCluster;
31+
type Object = Self;
3232
type Error = anyhow::Error;
3333

34-
fn parse(tree: &Element) -> Result<RegisterCluster> {
34+
fn parse(tree: &Element) -> Result<Self> {
3535
if tree.name == "register" {
3636
Ok(RegisterCluster::Register(Register::parse(tree)?))
3737
} else if tree.name == "cluster" {

src/svd/registerinfo.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,19 @@ pub struct RegisterInfo {
8585
}
8686

8787
impl Parse for RegisterInfo {
88-
type Object = RegisterInfo;
88+
type Object = Self;
8989
type Error = anyhow::Error;
9090

91-
fn parse(tree: &Element) -> Result<RegisterInfo> {
91+
fn parse(tree: &Element) -> Result<Self> {
9292
let name = tree.get_child_text("name")?;
93-
RegisterInfo::_parse(tree, name.clone()).with_context(|| format!("In register `{}`", name))
93+
Self::_parse(tree, name.clone()).with_context(|| format!("In register `{}`", name))
9494
}
9595
}
9696

9797
impl RegisterInfo {
98-
fn _parse(tree: &Element, name: String) -> Result<RegisterInfo> {
98+
fn _parse(tree: &Element, name: String) -> Result<Self> {
9999
let properties = RegisterProperties::parse(tree)?;
100-
Ok(RegisterInfo {
100+
Ok(Self {
101101
name,
102102
alternate_group: tree.get_child_text_opt("alternateGroup")?,
103103
alternate_register: tree.get_child_text_opt("alternateRegister")?,

src/svd/registerproperties.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ pub struct RegisterProperties {
4242
}
4343

4444
impl Parse for RegisterProperties {
45-
type Object = RegisterProperties;
45+
type Object = Self;
4646
type Error = anyhow::Error;
4747

48-
fn parse(tree: &Element) -> Result<RegisterProperties> {
49-
Ok(RegisterProperties {
48+
fn parse(tree: &Element) -> Result<Self> {
49+
Ok(Self {
5050
size: parse::optional::<u32>("size", tree)?,
5151
reset_value: parse::optional::<u32>("resetValue", tree)?,
5252
reset_mask: parse::optional::<u32>("resetMask", tree)?,

src/svd/usage.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ pub enum Usage {
1818
}
1919

2020
impl Parse for Usage {
21-
type Object = Usage;
21+
type Object = Self;
2222
type Error = anyhow::Error;
2323

24-
fn parse(tree: &Element) -> Result<Usage> {
24+
fn parse(tree: &Element) -> Result<Self> {
2525
let text = tree.get_text()?;
2626

2727
match &text[..] {

0 commit comments

Comments
 (0)