Is ownership in Rust just std::move in C++?
Is ownership in Rust just std::move in C++?
Nah, it is just Rust fans getting owned.
No. Every single heap allocated object in Rust is move by default, but ownership ensures that there is only one owner of a resource. This does not exist in C++.
You got things mixed up, user. Nobody here knows how to code. It's all a LARP.
And the ones that know how to code (me) don't use current toy languages like Rust, V or Zig.
>mfw all i do is C and Python
Why participate in a thread about programming if you don't actually know programming?
so its std::move except enforced?
Yes, but Rust ownership is stricter than that.
sounds like C++ can implement this by adding compiler flags to making copy constructors illegal
Impossible without breaking backwards compatibility.
Ownership is actually a bad thing.
It stops "race conditions" - however data races are _not_ a bug; won't fix
Yes they correlate with memory errors, such as use after free, but it is an inelegant solution. Furthermore, by effectively locking resources (compare to: GIL) it isn't really a "zero cost" abstraction, even if you try to frontload the work to the compiler.
>(compare to: GIL)
This has nothing to do with GIL. Please suggest a better option to prevent human errors.
Unironically GC
Just because you wrap your language in a bunch of buzzwords doesn't mean you get to violate the CAP theorem (which is ultimately what's being attempted with the ownership model)
You pick a GC'd lang like Go for "safe" concurrent code, and use a lang like C as your "unsafe" blocks.
> Any Forums: Rust is full of mindless zealots!
> Also Any Forums:
Garbage collection comes with big performance issues. Which is why discord replaced their Go projects with Rust.
Assembly in the top 10...
>C more popular than JavaScript
lmao imagine being so far out of touch with the reality
c/c+ chad reporting in
ownership exists in sepples too that's what raii and smart pointers are for
Compiler flags not even necessary, just assign delete to the copy ctor. I do this for all my classes as a matter of good hygiene
Apparently, an even better way to do this is to inherit from a simple base class with deleted copy constructors + assignment operators. boost::noncopyable provides just such a base class. I do not believe there is a compiler flag to do the same.