Skip to content

Commit

Permalink
Add a const new associated function to ram_storage!'s output
Browse files Browse the repository at this point in the history
Useful to generate statics with the necessary ram
  • Loading branch information
sosthene-nitrokey committed Dec 9, 2024
1 parent 0a22aa1 commit 491c79c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@ macro_rules! ram_storage { (
buf: [u8; $block_size * $block_count],
}

impl Default for $Backend {
fn default() -> Self {
$Backend {
impl $Backend {
pub const fn new() -> Self {
Self {
buf: [$erase_value; $block_size * $block_count],
}
}
}

impl Default for $Backend {
fn default() -> Self {
Self::new()
}
}

pub struct $Name<'backend> {
backend: &'backend mut $Backend,
}
Expand Down

0 comments on commit 491c79c

Please sign in to comment.