Skip to content

Commit

Permalink
Return directly the result of get_or_init for additional safety
Browse files Browse the repository at this point in the history
  • Loading branch information
prasannavl committed Oct 24, 2023
1 parent 4ab4d26 commit 8131d28
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/ain-rs-exports/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,9 @@ fn block_template_err_wrapper() -> &'static mut BlockTemplateWrapper {
// to never be used
static mut CELL: std::cell::OnceCell<BlockTemplateWrapper> = std::cell::OnceCell::new();
unsafe {
let _ = CELL.get_or_init(|| BlockTemplateWrapper(BlockTemplate::default()));
CELL.get_mut().unwrap()
let v = CELL.get_or_init(|| BlockTemplateWrapper(BlockTemplate::default()));
#[allow(mutable_transmutes)]
std::mem::transmute(v)
}
}

Expand Down

0 comments on commit 8131d28

Please sign in to comment.