Skip to main content Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. Rust
  4. pw_kernel
  5. kernel
  6. with_static

with_static

Function with_static 

Source
pub fn with_static<T: 'static, F: FnOnce(&'static mut T)>(t: T, f: F) -> !
Expand description

Stores t in stack memory and provides a &'static mut T to a function which will never return.

Since F: FnOnce(...) -> !, the stack memory holding t will never be reclaimed, and so it can live forever (ie, be referenced using &'static mut T).

If f unwinds, with_static will loop {} forever to prevent t from being reclaimed.