Re: [TECH TOPIC] Rust for Linux

Geert Uytterhoeven
2021-07-08T14:34:00Z

Hi Miguel,

On Thu, Jul 8, 2021 at 4:28 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
> On Thu, Jul 8, 2021 at 4:18 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > 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

What if I would ignore that? I.e.

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

?

Please forgive my silly questions, I'm a Rust newbie ;-)

> }

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds