Access content of StaticCell

In a project, I am trying to use a StaticCell. However, it is unclear to me how I later use the cell. I thought I could access its content using some borrow or borrow_mut type methods, but did not figure out how to do this.

use static_cell::StaticCell;

struct Foo {
    x: u8,

static FOO: StaticCell<Foo> = StaticCell::new();

impl Foo {
    pub fn get_x(&self) -> u8 {

fn main() {
    let f = FOO.init_with(|| {
        Foo { x: 7 }

    let x = f.get_x(); // works
    // but how do I access the content of FOO without using the value returned by "init"?

You can't do this with a StaticCell. Use std::sync::OnceLock instead.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.