Re: [TECH TOPIC] Rust for Linux

Miguel Ojeda
2021-07-08T14:28:36Z

On Thu, Jul 8, 2021 at 4:18 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Exactly.

I had a feeling... :)

> Let's assume the caller access a member of the object regardless.
> What happens?

That is the key: they cannot access it to begin with because the
returned `Option` is empty, so there is not even an object you can
"access", thus asking "what happens?" does not have a meaning.

In code:

pub fn f(weak: Weak<i32>) {
let strong = weak.upgrade();

if let Some(content) = strong {
println!("{}", content);
}

// There is no `content` here, so you cannot do anything with it
}

Cheers,
Miguel