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 {
|
unsafe {
|
||||||
// Safety: ACTIVE_CLOCKS is only set in `init` and never modified after that.
|
// 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.
|
/// Get the active clock configuration.
|
||||||
pub fn get() -> &'static Clocks {
|
pub fn get<'a>() -> &'a Clocks {
|
||||||
unwrap!(Self::try_get())
|
unwrap!(Self::try_get())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user