diff --git a/subjects/boxing_todo/README.md b/subjects/boxing_todo/README.md index 508a2507..56efc5bd 100644 --- a/subjects/boxing_todo/README.md +++ b/subjects/boxing_todo/README.md @@ -2,7 +2,7 @@ ### Instructions -The objective is create an api to parse a list of _todos_ that is organized in a JSON file, +The objective is to create an api to parse a list of _todos_ that is organized in a JSON file, handling all possible errors in a multiple error system. Organization of the JSON file: @@ -17,9 +17,9 @@ Organization of the JSON file: } ``` -#### Error.rs +#### err.rs -Create a module in another file called **error.rs** which handles the boxing of errors. +Create a module in another file called **err.rs** which handles the boxing of errors. This module must implement an `enum` called `ParseErr` which will take care of the parsing errors. It must have the following elements: @@ -29,8 +29,8 @@ parsing errors. It must have the following elements: A structure called `ReadErr` which will take care of the reading errors, having just an element called `child_err` of type `Box`. For each data structure you will have to implement a function called `fmt` for the trait `Display` which writes -out the message **"Failed to parse todo"** in case it is a parsing error. Otherwise, it should write the message -**"Failed to read todo file"**. +out the message **"Fail to parse todo"** in case it is a parsing error. Otherwise, it should write the message +**"Fail to read todo file"**. For the `Error` trait the following functions (methods) have to be implemented: - `source` which returns an `Option` with the error: @@ -54,7 +54,7 @@ Basically it must parse and read the JSON file and return the `TodoList` if ever ### Expected Functions -For **error.rs** +For **err.rs** ```rust use std::fmt; @@ -99,23 +99,23 @@ impl Error for ReadErr { for **lib.rs** ```rust -mod error; -use error::{ ParseErr, ReadErr }; +mod err; +use err::{ ParseErr, ReadErr }; pub use json::{parse, stringify}; pub use std::error::Error; #[derive(Debug, Eq, PartialEq)] pub struct Task { - id: u32, - description: String, - level: u32, + pub id: u32, + pub description: String, + pub level: u32, } #[derive(Debug, Eq, PartialEq)] pub struct TodoList { - title: String, - tasks: Vec, + pub title: String, + pub tasks: Vec, } impl TodoList { @@ -168,6 +168,6 @@ And its output: $ cargo run TodoList { title: "TODO LIST FOR PISCINE RUST", tasks: [Task { id: 0, description: "do this", level: 0 }, Task { id: 1, description: "do that", level: 5 }] } Todo List parse failed: None -Fail to parses todo Some(Malformed(UnexpectedCharacter { ch: ',', line: 2, column: 18 })) +Fail to parse todo Some(Malformed(UnexpectedCharacter { ch: ',', line: 2, column: 18 })) $ ``` diff --git a/subjects/does_it_fit/README.md b/subjects/does_it_fit/README.md index 6980ce3c..64c0d0e8 100644 --- a/subjects/does_it_fit/README.md +++ b/subjects/does_it_fit/README.md @@ -6,7 +6,7 @@ Using the `areas_volumes` module provided, create two **functions**: - `area_fit` which receives 6 arguments and returns a boolean: - - `x` and `y`, length and width of the square in which it is going to be tried to fit the geometrical shapes (both usize) + - `x` and `y`, length and width of the Rectangle in which it is going to be tried to fit the geometrical shapes (both usize) - `objects`, the type of geometrical shape(s) which are going to be tried to be fitted in the square (areas_volumes::GeometricalShapes) - `times`, the number of geometrical shapes which are going to be tried to be fitted in the square (usize) - `a` and `b`, the dimensions which the plane(s) shape(s) passed will have (both usize) @@ -20,7 +20,7 @@ Using the `areas_volumes` module provided, create two **functions**: - `objects`, the type of geometrical volume(s) which are going to be tried to be fitted in the box (areas_volumes::GeometricalVolumes) - `times`, the number of geometrical volumes which are going to be tried to be fitted in the box (usize) - `a`, `b` and `c`, the dimensions which the geometrical volume(s) passed will have (all of them usize) - - `a` will refer to the side of the Cube, the radius of the Sphere, the side_a of the Parallelepipede, the area of the base of the Triangular Pyramid or the base radius of the Cone + - `a` will refer to the side of the Cube, the radius of the Sphere, the side_a of the Parallelepiped, the area of the base of the Triangular Pyramid or the base radius of the Cone - `b` will refer to the side_b of the Parallelepiped, the height of the Triangular Pyramid or the height of the Cone - `c` will refer to the side_c of the Parallelepiped - `volume_fit` should return `true` if the geometrical volume(s) fit inside of the box. @@ -128,7 +128,7 @@ fn main() { volume_fit(5, 5, 5, GeometricalVolumes::Sphere, 3, 2, 0, 0) ); println!( - "Do 3 triangles (5 base and 3 height) fit in a 5 by 7 by 5 box? {}", + "Does 1 parallelepiped (6 base, 7 height and depth 4) fit in a 5 by 7 by 5 parallelepiped? {}", volume_fit(5, 7, 5, GeometricalVolumes::Parallelepiped, 1, 6, 7, 4) ); } @@ -141,6 +141,6 @@ $ cargo run Do 100 rectangles (2x1) fit in a 2 by 4 square? false Do 3 triangles (5 base and 3 height) fit in a 5 by 5 square? true Do 3 spheres (2 radius) fit in a 5 by 5 by 5 box? true -Do 3 triangles (5 base and 3 height) fit in a 5 by 7 by 5 box? true +Does 1 parallelepiped (6 base, 7 height and depth 4) fit in a 5 by 7 by 5 parallelepiped? true $ ``` diff --git a/subjects/error_types/README.md b/subjects/error_types/README.md index 7e097dfd..ce5c605f 100644 --- a/subjects/error_types/README.md +++ b/subjects/error_types/README.md @@ -44,6 +44,12 @@ ex: ("password", "asdaSD\_") - [Error types](https://doc.rust-lang.org/rust-by-example/error/multiple_error_types/define_error_type.html) - [Struct NaiveDate](https://docs.rs/chrono/0.4.19/chrono/naive/struct.NaiveDate.html) + +### Dependencies + +chrono = "0.4" + + ### Expected Function ```rust @@ -60,8 +66,8 @@ impl FErr { #[derive(Debug, Eq, PartialEq)] pub enum SexType { - // expected public fields } + #[derive(Debug, Eq, PartialEq)] pub struct Form { // expected public fields @@ -87,8 +93,8 @@ use error_types::*; fn main() { let mut form_output = Form::new( - String::from("Alice"), - String::from("Bear"), + String::from("Lee"), + String::from("Silva"), create_date("2015-09-05"), SexType::Male, String::from("Africa"), diff --git a/subjects/unwrap_or_expect/README.md b/subjects/unwrap_or_expect/README.md index de082b94..5ad1f0bb 100644 --- a/subjects/unwrap_or_expect/README.md +++ b/subjects/unwrap_or_expect/README.md @@ -2,19 +2,20 @@ ### Instructions -A **function** called **odd_to_even** will be given, which returns a `Result`. If an error occurs the function will -return a tuple with a string, stating the error, and a vector with the elements which causing the error. +A **function** called **odd_to_even** will be given, which returns a `Result`. If there is an even value in the vector, the function will +return a tuple with a string, stating the error, and a vector with the elements that caused the error. + The objective is to execute the `odd_to_even` function and handle the error returned by it. Create the following functions which receives a vector : -- `expect` which returns the error adding the string "ERROR " +- `expect` which returns the error adding the string "ERROR" - `unwrap_or` which in case of error returns an empty vector - `unwrap_err` which returns error if its `Ok` and returns the string containing the error in case of `Err` - `unwrap` which unwraps the `Result` -- `unwrap_or_else` which in case of error returns the vector of elements which causes the error +- `unwrap_or_else` which in case of error returns the vector of elements that caused the error ### Notions