Browse Source

fixing boxing_todo

pull/1112/head
miguel 3 years ago
parent
commit
debf919e4c
  1. 14
      subjects/boxing_todo/README.md

14
subjects/boxing_todo/README.md

@ -119,12 +119,10 @@ impl TodoList {
Here is a program to test your function. Here is a program to test your function.
You can create some todos yourself to test it. The JSON structure can be found above. You can create some _todos_ yourself, inside the boxing_todo file in order to test it. The JSON structure can be found above.
```rust ```rust
mod lib; use boxing_todo::TodoList;
use lib::{ TodoList };
fn main() { fn main() {
let todos = TodoList::get_todo("todo.json"); let todos = TodoList::get_todo("todo.json");
match todos { match todos {
@ -133,15 +131,13 @@ fn main() {
println!("{}{:?}", e.to_string(), e.source()); println!("{}{:?}", e.to_string(), e.source());
} }
} }
let todos = TodoList::get_todo("todo_empty.json");
let todos = TodoList::get_todo("no_todo_list.json");
match todos { match todos {
Ok(list) => println!("{:?}", list), Ok(list) => println!("{:?}", list),
Err(e) => { Err(e) => {
println!("{}{:?}", e.to_string(), e.source()); println!("{}{:?}", e.to_string(), e.source());
} }
} }
let todos = TodoList::get_todo("malformed_object.json"); let todos = TodoList::get_todo("malformed_object.json");
match todos { match todos {
Ok(list) => println!("{:?}", list), Ok(list) => println!("{:?}", list),
@ -157,7 +153,7 @@ And its output:
```console ```console
$ cargo run $ 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 }] } 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 todoNone
Fail to parse todo Some(Malformed(UnexpectedCharacter { ch: ',', line: 2, column: 18 })) Fail to parse todo Some(Malformed(UnexpectedCharacter { ch: ',', line: 2, column: 18 }))
$ $
``` ```
@ -167,4 +163,4 @@ $
- [Module std::fmt](https://doc.rust-lang.org/std/fmt/) - [Module std::fmt](https://doc.rust-lang.org/std/fmt/)
- [JSON](https://docs.rs/json/0.12.4/json/) - [JSON](https://docs.rs/json/0.12.4/json/)
- [Boxing errors](https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/boxing_errors.html) - [Boxing errors](https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/boxing_errors.html)
- [Returning Traits wirh dyn](https://doc.rust-lang.org/stable/rust-by-example/trait/dyn.html) - [Returning Traits with dyn](https://doc.rust-lang.org/stable/rust-by-example/trait/dyn.html)

Loading…
Cancel
Save