Typo/grammar fixes plus copy edits for Rust roadmap (19 files) (#5906)
* Fix typos Rust/100-integers.md * Grammatical clarity Rust/101-why-rust.md * Sentence restructuring for Rust/102-memory-safety.md * Additional linker explanation for newbies, Rust/103-installing-rust.md * Wording changes, Rust/103-installing-rust.md * "tools for debugging" -> "debugging tools" Rust/104-ides-and-rust.md * Small clarity change Rust/105-rust-repl.md * "systems" -> "system" (for consistency), Rust/101-why-rust.md * Clarity, Rust/101-variables.md * Small sentence edits, Rust/102-control-flow.md * Another small edit, 102-control-flow.md * Small changes + added `return` keyword info, Rust/103-functions.md * Rust/103-functions.md * Clarity/grammar for Rust/104-pattern-matching.md * Sentence flow + prose about pattern matching, Rust/100-syntax/index.md * Wording/paragraph improvements, Rust/100-syntax/index.md * List-ified, italics-ified for Rust/101-ownership/100-rules.md * Small changes + bullets for Rust/102-stack-heap.md * List-ify + small clarity improvements, Rust/101-ownership/index.md * Sentence flow & clarity for Rust/102-constructs/100-enums.md * Rewrite of Rust/100-enums.md * a -> an * List-ify and small edits for Rust/101-structs.md * Bold some stuff in Rust/101-structs.md * Small rewrite for Rust/102-traits.md * Rewrite Rust/103-impl-blocks.md * List-ify + clarity edits for Rust/102-constructs/index.md * More data types explanation for Rust/102-constructs/index.md * define -> declare * Update index.md * Unbolded “traits” * Unbolded “enum” + replaced em-dashes with commas * “Rust is a system…” * Replaced em-dashes with commas * Update 102-control-flow.md Replaced more em-dashes with commas * Unbold “struct” * Unbold “constructs”pull/5915/head
parent
2da1f61945
commit
64bbbc2f25
19 changed files with 77 additions and 31 deletions
@ -1,7 +1,7 @@ |
|||||||
# Memory Safety and Zero-Cost Abstractions |
# Memory Safety and Zero-Cost Abstractions |
||||||
|
|
||||||
Rust, a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety. It is graced with the feature of "memory safety without garbage collection", an attribute that makes Rust one of its kind. Memory safety is ensuring that software, while accessing the system's memory, is not causing any leaks, or dangling pointers. In Rust, memory safety is accomplished through a system of ownership with a set of rules that the compiler checks at compile time. This system eliminates the need of garbage collection or manual memory management, hence ensuring swift execution of software along with a safer memory environment. This memory management feature in Rust even provides concurrent programming guaranteeing thread safety with options for shared and mutable state access that makes it harder to cause thread unsafety. |
Rust is a system programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety. It is graced with the feature of "memory safety without garbage collection," an attribute that makes Rust one of a kind. "Memory safety" is ensuring that software is not causing any memory leaks or dangling pointers while accessing the system's memory. In Rust, memory safety is accomplished through a system called ownership, with a set of rules that the compiler checks at compile time. This ownership system eliminates the need for garbage collection or manual memory management, thus ensuring swift execution of software and a safer memory environment. Rust's memory management features even support concurrent programming, providing options for shared and mutable state access that ensure thread safety while reducing the risk of thread unsafety. |
||||||
|
|
||||||
<!-- Adding content on Zero-cost Abstraction --> |
<!-- Adding content on Zero-cost Abstraction --> |
||||||
|
|
||||||
Zero cost abstraction is another key feature of Rust. In general, abstractions in programming languages allow code to be written at a high level (like in Python), while being able to run at a low level (like in C). However, these abstractions often come with a runtime cost. Rust aims to provide abstractions that are as fast as writing the code manually at a low level. This means you can write high-level code, and the Rust compiler will optimize it to run as fast as manually written low-level code. |
Zero-cost abstraction is another key concept Rust implements. In general, abstractions in programming languages allow code to be written at a high level (like in Python), while being able to run at a low level (like in C). However, these abstractions often come with a runtime cost. In contrast, Rust aims to provide many useful abstractions, such as iterators and closures, that don't sacrifice runtime performance. This means you can write high-level code in Rust, and the Rust compiler will optimize it to run as fast as manually written low-level code. |
||||||
|
@ -1,3 +1,7 @@ |
|||||||
# Installing Rust and Cargo |
# Installing Rust and Cargo |
||||||
|
|
||||||
To install Rust, navigate to the official website at [https://www.rust-lang.org](https://www.rust-lang.org) and download the appropriate installation file for your operating system. For UNIX systems like Linux and MacOS, installation is as easy as running a single command in the terminal. For Windows, you'll be provided with a '.exe' installer which you need to execute. Further instructions can be found on the download page of the website. Keep in mind that you'll also need a linker of your operating system such as 'gcc'. You can update your Rust version at any time by running `rustup update` in the terminal. |
To install Rust, navigate to the official website at [https://www.rust-lang.org](https://www.rust-lang.org) and download the appropriate installation file (or run the appropriate terminal command) for your operating system. You'll be installing `rustup`, which is the preferred tool for installing, updating, and managing your core Rust tooling. For UNIX systems like Linux and MacOS, installation is as easy as running a single command in the terminal. For Windows, you'll be provided with an '.exe' installer which you need to execute. Further instructions can be found on the download page of the website. |
||||||
|
|
||||||
|
Keep in mind that for the compiler to create executables, you'll also need a linker on your operating system, such as 'GCC'. Otherwise, you'll encounter errors when you try to run `rustc` or `cargo`. This is one necessary thing that `rustup` doesn't install for you. Such linker components are part of the C standard library, so they may or may not be partially or fully preinstalled on your system. For example, a common error when running `rustc` for the first time in a 64-bit Linux environment is that your system is missing 32-bit support for GCC, which can be solved by installing `gcc-multilib`. |
||||||
|
|
||||||
|
You can update your Rust version at any time by running `rustup update` in the terminal. |
||||||
|
@ -1,3 +1,3 @@ |
|||||||
# IDEs and Rust Toolchains |
# IDEs and Rust Toolchains |
||||||
|
|
||||||
For the Rust Programming Language, several Integrated Development Environments (IDEs) and editors provide great support. [Visual Studio Code](https://code.visualstudio.com) is highly preferred among Rust developers due to its support for Rust via the "Rust Language Server" or "rust-analyzer" plugins. Another popular choice is [RustRover](https://www.jetbrains.com/rust/), a dedicated IDE for Rust development by JetBrains. Additionally, [Sublime Text](https://www.sublimetext.com) and [Atom](https://atom.io) with respective Rust-enhancement plugins are also used. For a more terminal-centric approach, [Vim](https://www.vim.org) and [Emacs](https://www.gnu.org/software/emacs/) are equipped with Rust modes. These IDEs and editors offer various features like auto-completion, syntax highlighting, and tools for debugging which prove useful for Rust programming. |
For the Rust Programming Language, several Integrated Development Environments (IDEs) and editors provide great support. [Visual Studio Code](https://code.visualstudio.com) is highly preferred among Rust developers due to its support for Rust via the "Rust Language Server" or "rust-analyzer" plugins. Another popular choice is [RustRover](https://www.jetbrains.com/rust/), a dedicated IDE for Rust development by JetBrains. Additionally, [Sublime Text](https://www.sublimetext.com) and [Atom](https://atom.io) with respective Rust-enhancement plugins are also used. For a more terminal-centric approach, [Vim](https://www.vim.org) and [Emacs](https://www.gnu.org/software/emacs/) are equipped with Rust modes. These IDEs and editors offer various features like auto-completion, syntax highlighting, and debugging tools which prove useful for Rust programming. |
||||||
|
@ -1,3 +1,3 @@ |
|||||||
# Rust REPL (Rust Playground) |
# Rust REPL (Rust Playground) |
||||||
|
|
||||||
`Rust REPL` (Read-Eval-Print-Loop) is an interactive shell in which you can write and test Rust snippets in real-time. Unlike running a program normally in Rust where you have to manually compile and then run the program, in REPL the inputs are automatically evaluated, and the result is returned immediately after execution. This is helpful when experimenting with Rust code, learning the language, and debugging. REPL isn't built into Rust directly but is available via third-party tools such as `evcxr_repl`. |
`Rust REPL` (Read-Eval-Print-Loop) is an interactive shell in which you can write and test Rust snippets in real-time. Unlike running a program normally in Rust where you have to manually compile and then run the program, REPL automatically evaluates your inputs, and the result is returned immediately after execution. This is helpful when experimenting with Rust code, learning the language, and debugging. REPL isn't built into Rust directly, but is available via third-party tools such as `evcxr_repl`. |
||||||
|
@ -1,3 +1,7 @@ |
|||||||
# Syntax and Semantics |
# Syntax and Semantics |
||||||
|
|
||||||
Rust's syntax aims for readability and avoids visual clutter. It places a great deal of importance on forward compatibility, even when it occasionally hinders feature additions. Most Rust syntax is based on the same basic principles. Understanding a handful of concepts allows a broad understanding of the structure of most Rust programs. Some of these concepts include item declarations and pattern matching. In Rust, you typically declare an item once and then refer to it by its name. Pattern matching is a fundamental and powerful part of Rust’s syntax, allowing you to branch your code based on the structure of data, not just its value or type. |
Rust's syntax aims for readability and reduced visual clutter. Rust also places a great deal of importance on forward compatibility, even when it occasionally hinders feature additions. |
||||||
|
|
||||||
|
Most syntax in Rust is built around the same basic principles, so understanding a handful of Rust's core concepts allows for a broad understanding of the structure of most Rust programs. Examples of Rust's most widely-used syntactic components are item declarations and pattern matching. In Rust, you typically declare an item once and then refer to it by its name as long as it's in scope. Pattern matching is a fundamental and powerful part of Rust's syntax: it allows you to branch code based on the structure of its data, not just its value or type. |
||||||
|
|
||||||
|
It takes time to learn all of Rust's paradigms for constructing the most robust and elegant pattern matching (e.g., by implementing your own data types). However, even complex pattern matching can be intuitive to read and concise, which is what makes it so powerful. |
||||||
|
@ -1,3 +1,7 @@ |
|||||||
# Ownership System |
# Ownership System |
||||||
|
|
||||||
In Rust, the concept of `Ownership` is a key feature that governs how memory management works. Each value in Rust has its own designated owner and there can be only one owner for a value at a time. When the owner goes out of scope, the value would be automatically dropped. The three main facets of ownership include ownership rules, `borrowing` and `slices`. Ownership rules play a key role in system performance and prevention of issues like null or dangling references. `Borrowing` is a mechanism where we allow something to reference a value without taking ownership. Finally, `slices` are a data type that does not have ownership and helps in making a reference to a portion of a collection. |
In Rust, the concept of **ownership** is a key feature that governs how memory management works. Each value in Rust has its own designated "owner," and there can be only one owner for a value at a time. When the owner goes out of scope, whatever value it owns is automatically _dropped_ from memory. The three main facets of ownership include ownership rules, borrowing, and slices. |
||||||
|
|
||||||
|
- **Ownership rules** play a key role in system performance and prevention of issues, such as null or dangling references. |
||||||
|
- **Borrowing** is a mechanism where we allow something to _reference_ a value without taking _ownership_. |
||||||
|
- **Slices** are a data type that does _not_ have ownership. Specifically, slices help in making a reference to a portion of a collection data type, like a `String`, `Array`, or `Vec`. |
||||||
|
@ -1,3 +1,10 @@ |
|||||||
# Constructs |
# Constructs |
||||||
|
|
||||||
In Rust, "constructs" refer to different elements used to build the structure of the program. This includes variables, functions, data types, control flow statements, and more. **Variables** store data, and their mutable or immutable status is determined at their declaration. **Functions** are reusable blocks of code defined by the `fn` keyword. Data types in Rust are static and must be declared upfront. These include simple ones like integers, boolean, float, etc, and complex types like arrays, tuples etc. **Control Flow** structures help direct the flow of execution. These include `if`, `else`, `loop`, `while`, `for`, and more. Exception handling uses the `Result` and `Option` enums along with the `match` construct. Rust's constructs like these come together to structure your program in a safe yet efficient manner. |
In Rust, "constructs" refer to different elements used to build the structure of the program. Constructs includes variables, functions, data types, control flow statements, and more. |
||||||
|
|
||||||
|
- **Variables** store data, and their immutable or mutable status is determined at their declaration with `let` and `let mut`, respectively. |
||||||
|
- **Functions** are reusable blocks of code defined by the `fn` keyword. |
||||||
|
- **Data types** in Rust are static and must be declared upfront. These include simple _primitive_ types, like integers, booleans (`bool`), and floats, as well as _complex_ types like arrays, tuples, all the custom types you declare yourself, and many more types you might use from Rust's standard library or community crates you download. |
||||||
|
- **Control flow** structures help direct the flow of code execution. These include `if`, `else`, `loop`, `while`, and `for` blocks, to name a few. Exception handling in Rust leverages the `Result<T, E>` and `Option<T>` enums alongside the `match` construct's ability to perform concise pattern matching. |
||||||
|
|
||||||
|
As a Rust programmer, you'll utilize many of the language's constructs like the ones above. These pieces come together at your fingertips to structure your program in a safe and efficient manner. |
||||||
|
Loading…
Reference in new issue