Skip to content

Commit

Permalink
Add double curly braces to all macro_rules!, to ensure result is alwa…
Browse files Browse the repository at this point in the history
…ys a block.
  • Loading branch information
t-moe committed Dec 2, 2024
1 parent a46f878 commit 2f71e06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions rtt-target/src/defmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn do_write(bytes: &[u8]) {
/// [`rtt_init`]: crate::rtt_init
#[macro_export]
macro_rules! rtt_init_defmt {
($mode:path, $size:expr) => {
($mode:path, $size:expr) => {{
let channels = $crate::rtt_init! {
up: {
0: {
Expand All @@ -92,14 +92,14 @@ macro_rules! rtt_init_defmt {
};

$crate::set_defmt_channel(channels.up.0);
};
}};

($mode:path) => {
$crate::rtt_init_defmt!($mode, 1024);
};

() => {
() => {{
use $crate::ChannelMode::NoBlockSkip;
$crate::rtt_init_defmt!(NoBlockSkip, 1024);
};
}};
}
4 changes: 2 additions & 2 deletions rtt-target/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ unsafe fn init_racy(logger: &'static Logger) {
/// [`rtt_init`]: crate::rtt_init
#[macro_export]
macro_rules! rtt_init_log {
($level:path, $mode:path, $size:expr) => {
($level:path, $mode:path, $size:expr) => {{
$crate::rtt_init_print!($mode, $size);
$crate::init_logger_with_level($level);
};
}};

($level:path, $mode:path) => {
$crate::rtt_init_log!($level, $mode, 1024);
Expand Down
8 changes: 4 additions & 4 deletions rtt-target/src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ macro_rules! rdbg {
/// [`rtt_init`]: crate::rtt_init
#[macro_export]
macro_rules! rtt_init_print {
($mode:path, $size:expr) => {
($mode:path, $size:expr) => {{
let channels = $crate::rtt_init! {
up: {
0: {
Expand All @@ -172,14 +172,14 @@ macro_rules! rtt_init_print {
};

$crate::set_print_channel(channels.up.0);
};
}};

($mode:path) => {
$crate::rtt_init_print!($mode, 1024);
};

() => {
() => {{
use $crate::ChannelMode::NoBlockSkip;
$crate::rtt_init_print!(NoBlockSkip, 1024);
};
}};
}

0 comments on commit 2f71e06

Please sign in to comment.