Codecademy / docs

Codecademy Docs is a collection of information for all things code. 📕
https://www.codecademy.com/resources/docs
758 stars 3.44k forks source link

[Concept Entry] Rust: Ownership #5052

Open rescgutierrez opened 3 weeks ago

rescgutierrez commented 3 weeks ago

Reason/inspiration (optional)

Many of Rust's advantages regarding security, speed, and avoidance of general errors in code are related to how it's compiler checks variable ownership. In specific, Rust ownership rules allow to leave aside a garbage collector for memory cleanup, prevents programmers from leaving and using dangling pointers, among other examples.

There's a complete chapter discussing ownership in Rust's main online book, that begins with "Ownership is Rust’s most unique feature and has deep implications for the rest of the language." The link to the book: https://rust-book.cs.brown.edu/ch04-00-understanding-ownership.html

It is not only the most unique feature of the language, but also the one that is harder to get used to. Because of this there are ownership related excercises at the end of many chapters.

The page for this concept should be ownership.md in docs/content/rust/concepts/ownership. It should include a few examples of unsafe code, and how Rust ownership rules prevent its compilation. The examples should be the minimum necessary to show how Rust is different from other languages regarding code safety, and refer readers to the book for more details. A full explanation of the concept and its application could be very lengthy.

Entry Type (select all that apply)

New Concept Entry for Existing Topic

Code of Conduct

For Maintainers

rescgutierrez commented 3 weeks ago

Hi. I could work on this issue, since I'm currently gaining experience in Rust. @Sriparno08

Sriparno08 commented 3 weeks ago

Sounds good, @rescgutierrez. Let's implement the following:

It should include a few examples of unsafe code, and how Rust ownership rules prevent its compilation. The examples should be the minimum necessary to show how Rust is different from other languages regarding code safety, and refer readers to the book for more details.

Let's leave this out since it can be very lengthy:

A full explanation of the concept and its application could be very lengthy.

I'm assigning this issue to you. Please refer to the concept entry template, content standards and markdown style guide when working on the PR for this issue.