1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-01-05 16:10:31 +02:00

Capitalization in src/memory-management/rust.md

This commit is contained in:
Fabian Bornhofen 2023-01-12 11:50:28 +01:00 committed by GitHub
parent f750f75db6
commit 7203bb8a65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,15 +5,15 @@ Memory management in Rust is a mix:
* Safe and correct like Java, but without a garbage collector.
* Depending on which abstraction (or combonation of abstractions) you choose, can be a single unique pointer, reference counted, or atomically reference counted.
* Scope-based like C++, but the compiler enforces full adherence.
* A rust user can choose the right abstraction for the situation, some even have no cost at runtime like C.
* A Rust user can choose the right abstraction for the situation, some even have no cost at runtime like C.
It achieves this by modeling _ownership_ explicitly.
<details>
* If asked how at this point, you can mention that in rust this is usually handled by RAII wrapper types such as [Box], [Vec], [Rc], or [Arc]. These encapsulate ownership and memory allocation via various means, and prevent the potential errors in C.
* If asked how at this point, you can mention that in Rust this is usually handled by RAII wrapper types such as [Box], [Vec], [Rc], or [Arc]. These encapsulate ownership and memory allocation via various means, and prevent the potential errors in C.
* You may be asked about destructors here, the [Drop] trait is the rust equivalent.
* You may be asked about destructors here, the [Drop] trait is the Rust equivalent.
</details>
@ -21,4 +21,4 @@ It achieves this by modeling _ownership_ explicitly.
[Vec]: https://doc.rust-lang.org/std/vec/struct.Vec.html
[Rc]: https://doc.rust-lang.org/std/rc/struct.Rc.html
[Arc]: https://doc.rust-lang.org/std/sync/struct.Arc.html
[Drop]: https://doc.rust-lang.org/std/ops/trait.Drop.html
[Drop]: https://doc.rust-lang.org/std/ops/trait.Drop.html