mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-30 05:40:39 +00:00
Fix warning: 'creating a shared reference to mutable static is discouraged' (#2230)
* Fix warning: 'creating a shared reference to mutable static is discouraged' * Shorten lifetime of Clocks reference
This commit is contained in:
parent
3bb49b049a
commit
feaf66847c
@ -319,15 +319,16 @@ impl Clocks {
|
||||
})
|
||||
}
|
||||
|
||||
fn try_get() -> Option<&'static Clocks> {
|
||||
fn try_get<'a>() -> Option<&'a Clocks> {
|
||||
unsafe {
|
||||
// Safety: ACTIVE_CLOCKS is only set in `init` and never modified after that.
|
||||
ACTIVE_CLOCKS.as_ref()
|
||||
let clocks = &*core::ptr::addr_of!(ACTIVE_CLOCKS);
|
||||
clocks.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the active clock configuration.
|
||||
pub fn get() -> &'static Clocks {
|
||||
pub fn get<'a>() -> &'a Clocks {
|
||||
unwrap!(Self::try_get())
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user