Skip to content

Commit 43ea98a

Browse files
committed
Default fo Config
1 parent 9bc5ec6 commit 43ea98a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn run() -> Result<()> {
8282
let target = matches
8383
.value_of("target")
8484
.map(|s| Target::parse(s))
85-
.unwrap_or(Ok(Target::CortexM))?;
85+
.unwrap_or_else(|| Ok(Target::default()))?;
8686

8787
let xml = &mut String::new();
8888
match matches.value_of("input") {

src/util.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub const BITS_PER_BYTE: u32 = 8;
1313
/// that are not valid in Rust ident
1414
const BLACKLIST_CHARS: &[char] = &['(', ')', '[', ']', '/', ' ', '-'];
1515

16-
#[derive(Clone, Copy, PartialEq)]
16+
#[derive(Clone, Copy, PartialEq, Default)]
1717
pub struct Config {
1818
pub target: Target,
1919
pub nightly: bool,
@@ -49,6 +49,12 @@ impl Target {
4949
}
5050
}
5151

52+
impl Default for Target {
53+
fn default() -> Self {
54+
Self::CortexM
55+
}
56+
}
57+
5258
pub trait ToSanitizedPascalCase {
5359
fn to_sanitized_pascal_case(&self) -> Cow<str>;
5460
}

0 commit comments

Comments
 (0)