diff --git a/exercises/book/A3-traits-generics/mod.md b/exercises/book/A3-traits-generics/mod.md index 0f0705b0..cdfad6f6 100644 --- a/exercises/book/A3-traits-generics/mod.md +++ b/exercises/book/A3-traits-generics/mod.md @@ -5,7 +5,7 @@ ## A3 Local Storage Vec In this exercise, we'll create a type called `LocalStorageVec`, which is generic list of items that resides either on the stack or the heap, depending on its size. If its size is small enough for items to be put on the stack, the `LocalStorageVec` buffer is backed by an array. `LocalStorageVec` is not only generic over the type (`T`) of items in the list, but also by the size (`N`) of this stack-located array using a relatively new feature called ["const generics"](https://doc.rust-lang.org/reference/items/generics.html#const-generics). Once the `LocalStorageVec` contains more items than fit in the array, a heap based [`Vec`](https://doc.rust-lang.org/std/vec/struct.Vec.html) is allocated as space for the items to reside in. -**Within this exercise, the objectives are annotated with a number of stars (⭐), indicating the difficulty. You are likely not to be able to finish all exercises during the turorial session** +**Within this exercise, the objectives are annotated with a number of stars (⭐), indicating the difficulty. You are likely not to be able to finish all exercises during the tutorial session** **Questions** 1. When is such a data structure more efficient than a standard `Vec`? @@ -49,7 +49,7 @@ pub enum LocalStorageVec { ``` -### A3.B `impl`-ing `From` ⭐ +### A3.B `impl`-ing `From>` ⭐ Uncomment the test `it_from_vecs`, and add an implementation for `From>` to `LocalStorageVec`. To do so, copy the following code in your `lib.rs` file and replace the `todo!` macro invocation with your code that creates a heap-based `LocalStorageVec` containing the passed `Vec`. diff --git a/slides/A1-intro-to-rust.md b/slides/A1-intro-to-rust.md index 0ca3abf8..1bf0a20f 100644 --- a/slides/A1-intro-to-rust.md +++ b/slides/A1-intro-to-rust.md @@ -43,7 +43,7 @@ layout: default layout: section --- -# Anyone have experience with Rust? +# Anyone has experience with Rust? --- layout: cover @@ -208,7 +208,7 @@ error[E0384]: cannot assign twice to immutable variable `some_x` | help: consider making this binding mutable: `mut some_x` 3 | println!("some_x = {}", some_x); 4 | some_x = 6; - | ^^^^^^^^^^ c annot assign twice to immutable variable + | ^^^^^^^^^^ cannot assign twice to immutable variable For more information about this error, try `rustc --explain E0384`. error: could not compile `hello-world` due to previous error @@ -219,7 +219,7 @@ error: could not compile `hello-world` due to previous error @@ -327,8 +327,8 @@ fn main() { } ``` -- `f32`: single precision (32 bit) floating point number -- `f64`: double precision (64 bit) floating point number +- `f32`: single precision (32-bit) floating point number +- `f64`: double precision (64-bit) floating point number --- @@ -736,7 +736,7 @@ we need them somewhere else - We don't want to pass a copy all the time - Large data that we do not want to copy - Modifying original data -- What about datastructures with a variable size? +- What about data structures with a variable size? ::right:: @@ -891,7 +891,7 @@ The stack has limitations though, because it only grows as a result of a function call. * Size of items on stack frame must be known at compile time -* If I don't know the size of a variable upfront: What size should my stack +* If I don't know the size of a variable up front: What size should my stack frame be? * How can I handle arbitrary user input efficiently? @@ -1227,7 +1227,7 @@ layout: default * Loads of syntax * Values are owned by variables * Values may be moved to new owners or copied -* Some typse may be explicitly `Clone`d +* Some types may be explicitly `Clone`d --- layout: default diff --git a/slides/A2-advanced-intro.md b/slides/A2-advanced-intro.md index 8a951eb8..0d98209c 100644 --- a/slides/A2-advanced-intro.md +++ b/slides/A2-advanced-intro.md @@ -22,7 +22,7 @@ Advanced Rust syntax # Ownership We previously talked about ownership -* In rust there is always a single owner for each stack value +* In Rust there is always a single owner for each stack value * Once the owner goes out of scope any associated values should be cleaned up * Copy types creates copies, all other types are *moved* @@ -63,7 +63,7 @@ fn calculate_length(s: String) -> usize { borrow it from them, but eventually you have to give it back - If a value is borrowed, it is not moved and the ownership stays with the original owner -- To borrow in rust, we create a *reference* +- To borrow in Rust, we create a *reference* ```rust {all|3|7|all} fn main() { @@ -197,7 +197,7 @@ These rules are enforced by the Rust compiler. Combined with the ownership model we can be sure that whole classes of errors cannot occur. -* Rust is memory safe without having to use any runtime background proces such +* Rust is memory safe without having to use any runtime background process such as a garbage collector * But we still get the performance of a language that would normally let you manage memory manually @@ -512,6 +512,7 @@ fn accept_home(ip: IpAddress) { _ => { println!("You are not home"); }, + } } ``` @@ -550,7 +551,7 @@ struct PointFloat(f64, f64); struct PointInt(i64, i64); ``` -We are repeating ourselves here, what if we could write a datastructure for +We are repeating ourselves here, what if we could write a data structure for both of these cases? @@ -1052,7 +1053,7 @@ There are several reasons to box a variable on the heap * When something is too large to move around * We need something that is sized dynamically -* For writing recursive datastructures +* For writing recursive data structures ```rust struct Node { @@ -1068,7 +1069,7 @@ There are several reasons to box a variable on the heap * When something is too large to move around * We need something that is sized dynamically -* For writing recursive datastructures +* For writing recursive data structures ```rust struct Node { @@ -1128,7 +1129,7 @@ to support summing up only parts of a vector? * Contiguous: elements are layed out in memory such that they are evenly spaced * Dynamically sized: the size of the slice is not stored in the type, but is determined at runtime -* View: a slice is never an owned datastructure +* View: a slice is never an owned data structure * Slices are typed as `[T]`, where `T` is the type of the elements in the slice --- @@ -1168,7 +1169,7 @@ help: function arguments must have a statically known size, borrowed types alway @@ -1419,7 +1420,7 @@ It should be possible to have a reference to part of a string. But what is it? | - | `String` | `&str` | * There is no static variant of str -* This would only be useful if we wanted strings of an extact length +* This would only be useful if we wanted strings of an exact length * But just like we had the static slice literals, we can use `&'static str` literals for that instead! @@ -1460,7 +1461,7 @@ fn string_len(data: &str) -> usize { * Define methods and associated functions with impl blocks * Use `Vec` for growable array storage * Use `Box` to put something on the heap -* Use slices whenever possible instead of owned Vec and String types +* Use slices whenever possible instead of owned `Vec` and `String` types --- diff --git a/slides/A3-traits-generics.md b/slides/A3-traits-generics.md index e8e469cb..f43bd231 100644 --- a/slides/A3-traits-generics.md +++ b/slides/A3-traits-generics.md @@ -699,7 +699,7 @@ layout: default # What lifetime? - References refer to variable -- Varable has a lifetime: +- Variable has a lifetime: - Start at declaration - End at drop