From cb8e2ab297189b4f40eb96a036bfa6ca61ad906d Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 8 Feb 2021 13:51:22 +0000 Subject: [PATCH] clarifications and notions --- subjects/borrow_me_the_reference/README.md | 6 +++++- subjects/changes/README.md | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/subjects/borrow_me_the_reference/README.md b/subjects/borrow_me_the_reference/README.md index 64161052..4edd109e 100644 --- a/subjects/borrow_me_the_reference/README.md +++ b/subjects/borrow_me_the_reference/README.md @@ -7,7 +7,11 @@ needing garbage collector. Therefore you must understand ownership in rust. Create the following functions : - - `delete_and_backspace`, imagine that `-` represents the backspace key and the `+` represents the delete key, this function must receive a borrowed string and turn this string into the string without the backspaces and the deletes. + - `delete_and_backspace`, imagine that the `-` represents the `backspace key` and the `+` represents the `delete key`, this function must receive a borrowed string and turn this string into the string that applies the `backspaces` and the `deletes`. + - For example: + - "helll-o" turns into "hello" + + - "he+lllo" turns into "hello" - `is_correct` that borrows a Vector of string literals with some correct and incorrect math equations and replaces the correct equations with `✔` and the wrong with `✘` and returns a `usize` with the percentage of correct equations. diff --git a/subjects/changes/README.md b/subjects/changes/README.md index f6f096f2..01c5af92 100644 --- a/subjects/changes/README.md +++ b/subjects/changes/README.md @@ -2,11 +2,16 @@ ### Instructions -Imagine you are working in a software to control smart lights in a house. You have access to an array of all the lights in a house. +Imagine you are working on a software to control smart lights in a house. You have access to an array of all the lights in a house. -Define the associated function `new` to the data structure `Light` which creates a new light with the alias passed in the arguments and a brightness of 0. +Define the associated **function** `new` to the data structure `Light` which creates a new light with the alias passed in the arguments and a brightness of 0. -Define the function `change_brightness` that receives a Vec of lights, an alias and a u8 value and sets the u8 value as the new brightness of the light identified by the alias in the Vec of lights. +Define the **function** `change_brightness` that receives a `Vec` of lights, an `alias` and a `u8`value. The **function** then sets the `u8` value as the new brightness of the light identified by the alias in the Vec of lights. + +### Notions + +[Example of Structs](https://doc.rust-lang.org/book/ch05-02-example-structs.html) +[Keyword Self](https://doc.rust-lang.org/std/keyword.Self.html) ### Expected Functions and Structure @@ -31,6 +36,8 @@ pub fn change_brightness(lights: &mut Vec, alias: &str, value: u8) { Here is an incomplete program to test your function ```rust +use changes::*; + fn main() { // bedroom let mut lights = vec![