Re: [PATCH 00/13] [RFC] Rust support

From: Miguel Ojeda
Date: Fri Apr 16 2021 - 10:21:17 EST


On Fri, Apr 16, 2021 at 1:24 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> IMO RAII is over-valued, but just in case you care, the below seems to
> work just fine. No fancy new language needed, works today. Similarly you
> can create refcount_t guards, or with a little more work full blown
> smart_ptr crud.

Please note that even smart pointers (as in C++'s `std::unique_ptr`
etc.) do not guarantee memory safety. Yes, they help a lot writing
sound code (in particular exception-safe C++ code), but they do not
bring the same guarantees.

That's why using C language extensions (the existing ones, that is) to
recreate RAII/guards, smart pointers, etc. would only bring you to a
point closer to C++, but not to Rust.

Cheers,
Miguel