Add links to rust roadmap (#5009)

Co-authored-by: Kamran Ahmed <kamranahmed.se@gmail.com>
pull/5125/head^2
Agustin Velez 5 months ago committed by GitHub
parent 8d9605658f
commit 8fd4a0bd60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      src/data/roadmaps/rust/content/101-language-basics/100-syntax/102-control-flow.md
  2. 6
      src/data/roadmaps/rust/content/101-language-basics/100-syntax/103-functions.md
  3. 7
      src/data/roadmaps/rust/content/101-language-basics/100-syntax/104-pattern-matching.md
  4. 6
      src/data/roadmaps/rust/content/101-language-basics/101-ownership/100-rules.md
  5. 7
      src/data/roadmaps/rust/content/101-language-basics/101-ownership/101-borrowing.md
  6. 6
      src/data/roadmaps/rust/content/101-language-basics/101-ownership/102-stack-heap.md
  7. 11
      src/data/roadmaps/rust/content/101-language-basics/102-constructs/100-enums.md
  8. 6
      src/data/roadmaps/rust/content/101-language-basics/102-constructs/101-structs.md
  9. 6
      src/data/roadmaps/rust/content/101-language-basics/102-constructs/103-impl-blocks.md
  10. 6
      src/data/roadmaps/rust/content/101-language-basics/103-data-structures/100-integers.md
  11. 6
      src/data/roadmaps/rust/content/101-language-basics/103-data-structures/101-floats.md
  12. 6
      src/data/roadmaps/rust/content/101-language-basics/103-data-structures/102-boolean.md
  13. 6
      src/data/roadmaps/rust/content/101-language-basics/103-data-structures/103-character.md
  14. 6
      src/data/roadmaps/rust/content/101-language-basics/103-data-structures/104-tuple.md
  15. 6
      src/data/roadmaps/rust/content/101-language-basics/103-data-structures/105-array.md

@ -1,3 +1,7 @@
# Control Flow Constructs
In Rust, control flow is managed through various structures like `if`, `else`, `while`, `for`, and `match`. The `if` and `else` structures are used to execute different blocks of code based on certain conditions. Similar to other languages, `while` and `for` are used for looping over a block of code. The `while` loop repeats a block of code until the condition is false, and the `for` loop is used to iterate over a collection of values like an array or a range. The `match` structure is a powerful tool in Rust which can be used for pattern matching. It goes through different cases and executes the block where the match is found.
In Rust, control flow is managed through various structures like `if`, `else`, `while`, `for`, and `match`. The `if` and `else` structures are used to execute different blocks of code based on certain conditions. Similar to other languages, `while` and `for` are used for looping over a block of code. The `while` loop repeats a block of code until the condition is false, and the `for` loop is used to iterate over a collection of values like an array or a range. The `match` structure is a powerful tool in Rust which can be used for pattern matching. It goes through different cases and executes the block where the match is found.
Learn more from the following links:
- [Control Flow](https://rust-book.cs.brown.edu/ch03-05-control-flow.html)

@ -1,3 +1,7 @@
# Functions and Method Syntax
In Rust, functions are declared using the `fn` keyword. Each function takes a set of input variables with their specified types and may optionally return a type. The body of the function is contained within curly braces `{}`. Unlike other languages, in Rust you don't need to end the statement with a semicolon if it’s the last one in a block, making it the implicit return. If we want to return a value, we simply write the expression we want to return. An example of a function in Rust is `fn add(one: i32, two: i32) -> i32 { one + two }` where `one` and `two` are parameters of type `i32` and the function returns an integer of type `i32`.
In Rust, functions are declared using the `fn` keyword. Each function takes a set of input variables with their specified types and may optionally return a type. The body of the function is contained within curly braces `{}`. Unlike other languages, in Rust you don't need to end the statement with a semicolon if it’s the last one in a block, making it the implicit return. If we want to return a value, we simply write the expression we want to return. An example of a function in Rust is `fn add(one: i32, two: i32) -> i32 { one + two }` where `one` and `two` are parameters of type `i32` and the function returns an integer of type `i32`.
Learn more from the following links:
- [Functions](https://rust-book.cs.brown.edu/ch03-03-how-functions-work.html)

@ -1,3 +1,8 @@
# Pattern Matching and Destructuring
In Rust, `pattern matching` is a robust tool that allows you to destructure data types and perform conditional checks in a succinct and clear way. The main structures used for pattern matching are `match` and `if let`. The `match` keyword can be used to compare a value against a series of patterns and then execute code based on which pattern matches. Patterns can be made up of literal values, variable names, wildcards, and many other things. The `if let` allows you to combine `if` and `let` into a less verbose way to handle values that match a specific pattern. It's basically a nice syntax sugar over a `match` statement.
In Rust, `pattern matching` is a robust tool that allows you to destructure data types and perform conditional checks in a succinct and clear way. The main structures used for pattern matching are `match` and `if let`. The `match` keyword can be used to compare a value against a series of patterns and then execute code based on which pattern matches. Patterns can be made up of literal values, variable names, wildcards, and many other things. The `if let` allows you to combine `if` and `let` into a less verbose way to handle values that match a specific pattern. It's basically a nice syntax sugar over a `match` statement.
Learn more from the following links:
- [The match Control Flow Construct](https://rust-book.cs.brown.edu/ch06-02-match.html)
- [Concise Control Flow with if let](https://rust-book.cs.brown.edu/ch06-03-if-let.html)

@ -1,3 +1,7 @@
# Ownership Rules and Memory Safety
In Rust, the concept of ownership is described by three main rules. Firstly, each value in Rust has a variable that is called its owner. Secondly, there can only ever be one owner at a time. This prevents multiple parts of the code from trying to modify the data at once, potentially causing data races and inconsistencies. Lastly, when the owner goes out of scope, the value will be dropped. This ensures that Rust cleans up the allocated memory and other resources once they’re no longer required, thereby avoiding memory leaks.
In Rust, the concept of ownership is described by three main rules. Firstly, each value in Rust has a variable that is called its owner. Secondly, there can only ever be one owner at a time. This prevents multiple parts of the code from trying to modify the data at once, potentially causing data races and inconsistencies. Lastly, when the owner goes out of scope, the value will be dropped. This ensures that Rust cleans up the allocated memory and other resources once they’re no longer required, thereby avoiding memory leaks.
Learn more from the following links:
- [What Is Ownership?](https://rust-book.cs.brown.edu/ch04-01-what-is-ownership.html)

@ -1,3 +1,8 @@
# Borrowing, References, and Slices
In Rust, "borrowing" is a technique which allows you to access the data of a particular value while the owner retains control. There are two types of borrowing: mutable and immutable. Immutable borrowing means an owner can fondly permit several read-only borrows of a value at the same time as long as the value doesn't change. On the other hand, mutable borrowing allows only a single borrower at a time who can potentially modify the value. This practice is essential in maintaining the concept of ownership without violating any of its rules and avoiding the problem of dangling references.
In Rust, "borrowing" is a technique which allows you to access the data of a particular value while the owner retains control. There are two types of borrowing: mutable and immutable. Immutable borrowing means an owner can fondly permit several read-only borrows of a value at the same time as long as the value doesn't change. On the other hand, mutable borrowing allows only a single borrower at a time who can potentially modify the value. This practice is essential in maintaining the concept of ownership without violating any of its rules and avoiding the problem of dangling references.
Learn more from the following links:
- [References and Borrowing](https://rust-book.cs.brown.edu/ch04-02-references-and-borrowing.html)
- [The Slice Type](https://rust-book.cs.brown.edu/ch04-04-slices.html)

@ -1,3 +1,7 @@
# Deep Dive: Stack vs Heap
In most modern computer systems, memory management is split into two main parts: the stack and the heap. The **stack** is a section of memory that grows and shrinks automatically as functions are called and return. The data stored on the stack must have a known, fixed size. The **heap** is a section of memory that is used for data that needs to persist for longer than a single function-call. Data with dynamic size is stored on the heap. Rust, like many languages, has facilities for using these two types of memory, allowing developers fine-tuned control over memory usage.
In most modern computer systems, memory management is split into two main parts: the stack and the heap. The **stack** is a section of memory that grows and shrinks automatically as functions are called and return. The data stored on the stack must have a known, fixed size. The **heap** is a section of memory that is used for data that needs to persist for longer than a single function-call. Data with dynamic size is stored on the heap. Rust, like many languages, has facilities for using these two types of memory, allowing developers fine-tuned control over memory usage.
Learn more from the following links:
- [The Stack and the Heap](https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/the-stack-and-the-heap.html)

@ -1,14 +1,7 @@
# Enums
Enums, short for enumerations, allow you to define a type by enumerating its possible variants. An instance of an enum type could be any one of these variants, and in Rust, enums are incredibly versatile. Unlike enumerations in some other languages, these variants aren't restricted to a singular data type. You can attach data to each variant of the enum, and the data could have different types and amounts for each variant. It's also possible to embed structs and even other enums. Enums in Rust also enable pattern-matching, which allows you to compare a value to a series of patterns, handle it if it matches one of them, and execute code based on which pattern has been matched.
Enums are data structures that represent a data type with more than one variant. We can use the enums variants in our operations, we can only use the base enum for specifying that we will either return a variant from a function or assign it to a variable.
Example of enum:
Learn more from the following links:
```Rust
enum Vehicle {
Car,
MotorCycle,
Bicycle,
}
```
- [Defining an Enum](https://rust-book.cs.brown.edu/ch06-01-defining-an-enum.html)

@ -1,3 +1,7 @@
# Structs
In Rust, `struct` is a custom data type used for grouping related values together into one entity. It is similar to classes in other programming languages. Essentially, they create a new type that we can use to streamline complex data handling. There are three types of `struct` in Rust - classic `C` structs, tuple structs, and unit structs. Classic `C` structs are named-field struct and are the most commonly used. Tuple struct, while not being common, are useful when you want to couple together a few data points. Unit structs are useful in situations where you want to implement a trait on some type but don’t have any data that you want to store in the type itself.
In Rust, `struct` is a custom data type used for grouping related values together into one entity. It is similar to classes in other programming languages. Essentially, they create a new type that we can use to streamline complex data handling. There are three types of `struct` in Rust - classic `C` structs, tuple structs, and unit structs. Classic `C` structs are named-field struct and are the most commonly used. Tuple struct, while not being common, are useful when you want to couple together a few data points. Unit structs are useful in situations where you want to implement a trait on some type but don’t have any data that you want to store in the type itself.
Learn more from the following links:
- [Defining and Instantiating Structs](https://rust-book.cs.brown.edu/ch05-01-defining-structs.html)

@ -1,3 +1,7 @@
# Impl Blocks
Impl Block in rust is used to implement a trait or a struct. It is used to define the behavior of a trait or a struct.
Impl Block in rust is used to implement a trait or a struct. It is used to define the behavior of a trait or a struct.
Learn more from the following links:
- [Method Syntax](https://rust-book.cs.brown.edu/ch05-03-method-syntax.html)

@ -1,3 +1,7 @@
# Integers
In Rust, integers are a primitive data type that hold whole number values, both positive and negative. Integer types in Rust can be divided into two subcategories: signed and unsigned. Signed integers are those that can hold negative, zero, and positive values whereas unsigned integers only hold zero and positive values. They are denoted by "i" and "u" respectively followed by a number which represents the number of bits they occupy in memory. The available integer types are `i8`, `i16`, `i32`, `i64`, `i128` and `isize` (signed), and `u8`, `u16`, `u32`, `u64`, `u128` and `usize` (unsigned). In these types, the number after "i" or "u" denotes the size of the integer type in bits. The `isize` and `usize` types depend on the kind of computer your program is running on: 64 bits on a 64-bit architecture and 32 bits on a 32-bit architecture.
In Rust, integers are a primitive data type that hold whole number values, both positive and negative. Integer types in Rust can be divided into two subcategories: signed and unsigned. Signed integers are those that can hold negative, zero, and positive values whereas unsigned integers only hold zero and positive values. They are denoted by "i" and "u" respectively followed by a number which represents the number of bits they occupy in memory. The available integer types are `i8`, `i16`, `i32`, `i64`, `i128` and `isize` (signed), and `u8`, `u16`, `u32`, `u64`, `u128` and `usize` (unsigned). In these types, the number after "i" or "u" denotes the size of the integer type in bits. The `isize` and `usize` types depend on the kind of computer your program is running on: 64 bits on a 64-bit architecture and 32 bits on a 32-bit architecture.
Learn more from the following links:
- [Integer Types](https://rust-book.cs.brown.edu/ch03-02-data-types.html#integer-types)

@ -1,3 +1,7 @@
# Floats
In Rust, `floats` are used to represent floating-point numbers. They are defined as numerical values with fractional components. Rust supports two types of floating-point numbers: `f32` and `f64`. These are 32-bit and 64-bit in size, respectively. `f32` is a single-precision float, while `f64` has double precision. The default type is `f64` because on modern CPUs it’s roughly the same speed as `f32` but allows more precision. You can define a float in Rust like so: `let x: f32 = 3.0;`.
In Rust, `floats` are used to represent floating-point numbers. They are defined as numerical values with fractional components. Rust supports two types of floating-point numbers: `f32` and `f64`. These are 32-bit and 64-bit in size, respectively. `f32` is a single-precision float, while `f64` has double precision. The default type is `f64` because on modern CPUs it’s roughly the same speed as `f32` but allows more precision. You can define a float in Rust like so: `let x: f32 = 3.0;`.
Learn more from the following links:
- [Floating-Point Types](https://rust-book.cs.brown.edu/ch03-02-data-types.html#floating-point-types)

@ -1,3 +1,7 @@
# Boolean
`Boolean` in Rust is a basic data type that encapsulates the truth value. It is represented by `bool` keyword and can hold two values either `true` or `false`. Rust includes `boolean` as its primitive data type and operations like logical `AND (&&)`, logical `OR (||)`, and logical `NOT (!)` can be performed on these types of values. Boolean is primarily used in conditional statements like `if`, `while` etc. For example, `let is_raining: bool = true;` where `is_raining` is a boolean variable holding the value `true`.
`Boolean` in Rust is a basic data type that encapsulates the truth value. It is represented by `bool` keyword and can hold two values either `true` or `false`. Rust includes `boolean` as its primitive data type and operations like logical `AND (&&)`, logical `OR (||)`, and logical `NOT (!)` can be performed on these types of values. Boolean is primarily used in conditional statements like `if`, `while` etc. For example, `let is_raining: bool = true;` where `is_raining` is a boolean variable holding the value `true`.
Learn more from the following links:
- [The Boolean Type](https://rust-book.cs.brown.edu/ch03-02-data-types.html#the-boolean-type)

@ -1,3 +1,7 @@
# Character
In Rust, the `char` keyword is used to denote a character type. A `char` in Rust represents a Unicode Scalar Value, which means it can represent a lot more than just ASCII. Accented letters, Chinese/Japanese/Korean ideographs, emoji, and zero width spaces are all valid `char` Types in Rust. It uses 4 bytes to store a single character. It is defined with single quotes like `let x: char = 'z';`.
In Rust, the `char` keyword is used to denote a character type. A `char` in Rust represents a Unicode Scalar Value, which means it can represent a lot more than just ASCII. Accented letters, Chinese/Japanese/Korean ideographs, emoji, and zero width spaces are all valid `char` Types in Rust. It uses 4 bytes to store a single character. It is defined with single quotes like `let x: char = 'z';`.
Learn more from the following links:
- [The Character Type](https://rust-book.cs.brown.edu/ch03-02-data-types.html#the-character-type)

@ -1,3 +1,7 @@
# Tuple
In Rust, a **Tuple** is a type of data structure that holds a finite number of elements, each having potentially different types. Elements in a tuple are accessed using a dot (`.`) followed by the index of the value we want to get. For example, to declare a tuple that includes a `32-bit integer`, a `single-byte unsigned integer`, and a `floating point number`, we would write `let my_tuple: (i32, u8, f64) = (500, 2, 20.5);` The index of elements in a tuple start from `0`. So, to access the first element, use `my_tuple.0`, the second element `my_tuple.1`, and so on. Tuples can also be used for multiple declarations and assignments. Tuples are particularly useful when you want to group together items of different types.
In Rust, a **Tuple** is a type of data structure that holds a finite number of elements, each having potentially different types. Elements in a tuple are accessed using a dot (`.`) followed by the index of the value we want to get. For example, to declare a tuple that includes a `32-bit integer`, a `single-byte unsigned integer`, and a `floating point number`, we would write `let my_tuple: (i32, u8, f64) = (500, 2, 20.5);` The index of elements in a tuple start from `0`. So, to access the first element, use `my_tuple.0`, the second element `my_tuple.1`, and so on. Tuples can also be used for multiple declarations and assignments. Tuples are particularly useful when you want to group together items of different types.
Learn more from the following links:
- [The Tuple Type](https://rust-book.cs.brown.edu/ch03-02-data-types.html#the-tuple-type)

@ -1,3 +1,7 @@
# Array
In Rust, an `array` is a collection of elements of the same type, organized consecutively in memory. Unlike some other data structures in Rust, the size of an array must be known at compile time. This gives it a distinct advantage in memory efficiency. The size of the array cannot be changed after it has been declared. The syntax to declare an array in Rust is as follows: `let array_name: [type; size] = [elements];`. Here, `type` represents the data type of the elements, `size` is the number of elements and `elements` are the data held in the array. For example: `let numbers: [i32; 5] = [1, 2, 3, 4, 5];`. Elements in an array can be accessed using their indices, starting from 0. For instance, `numbers[0]` will return the first element `1` in the `numbers` array.
In Rust, an `array` is a collection of elements of the same type, organized consecutively in memory. Unlike some other data structures in Rust, the size of an array must be known at compile time. This gives it a distinct advantage in memory efficiency. The size of the array cannot be changed after it has been declared. The syntax to declare an array in Rust is as follows: `let array_name: [type; size] = [elements];`. Here, `type` represents the data type of the elements, `size` is the number of elements and `elements` are the data held in the array. For example: `let numbers: [i32; 5] = [1, 2, 3, 4, 5];`. Elements in an array can be accessed using their indices, starting from 0. For instance, `numbers[0]` will return the first element `1` in the `numbers` array.
Learn more from the following links:
- [The Array Type](https://rust-book.cs.brown.edu/ch03-02-data-types.html#the-array-type)
Loading…
Cancel
Save