Browse Source

uodate rust readme, adding dependencies & clarifications

pull/997/head
davidrobert99 2 years ago
parent
commit
853b793519
  1. 5
      subjects/borrow_me_the_reference/README.md
  2. 3
      subjects/card_deck/README.md
  3. 2
      subjects/circle/README.md
  4. 8
      subjects/copy/README.md
  5. 2
      subjects/handling/README.md
  6. 2
      subjects/hashing/README.md
  7. 4
      subjects/looping/README.md
  8. 8
      subjects/panic/README.md
  9. 2
      subjects/profanity_filter/README.md
  10. 6
      subjects/tuples/README.md

5
subjects/borrow_me_the_reference/README.md

@ -31,6 +31,11 @@ pub fn is_correct(v: &mut Vec<&str>) -> usize {
- [ownership](https://doc.rust-lang.org/book/ch04-00-understanding-ownership.html)
- [meval](https://docs.rs/meval/0.2.0/meval/)
### Dependencies
meval = "0.2"
### Usage
Here is a program to test your function

3
subjects/card_deck/README.md

@ -61,6 +61,9 @@ pub struct Card {
pub suit: Suit,
pub rank: Rank,
}
pub fn winner_card(car: Card) -> bool{
}
```
### Usage

2
subjects/circle/README.md

@ -28,7 +28,7 @@ Create the structures `Circle` and `Point` (which will be made of two coordinate
This snippets are incomplete and it is part of the exercise to discover how to complete them. In the [usage](#usage) you will find all the information that you need.
```rust
struct Circle {
pub struct Circle {
center //..
radius //..
}

8
subjects/copy/README.md

@ -25,13 +25,13 @@ The objective is to know how ownership works with different types.
### Expected Functions
```rust
pub fn nbr_function(c: u32) -> (u32, f64, f64) {
pub fn nbr_function(c: i32) -> (i32, f64, f64) {
}
pub fn str_function(a: String) -> (String, String) {
}
pub fn vec_function(b: Vec<u32>) -> (Vec<u32>, Vec<f64>) {
pub fn vec_function(b: Vec<i32>) -> (Vec<i32>, Vec<f64>) {
}
```
@ -43,7 +43,7 @@ Here is a possible program to test your function :
use copy::*;
fn main() {
let a: u32 = 0;
let a: i32 = 0;
let b = String::from("1 2 4 5 6");
let c = vec![1, 2, 4, 5];
@ -61,7 +61,7 @@ And its output:
```console
$ cargo run
(0, 1.0, inf)
(0, 1.0, -inf)
("1 2 4 5 6", "2.718281828459045 7.38905609893065 54.598150033144236 148.4131591025766 403.4287934927351")
([1, 2, 4, 5], [0.0, 0.6931471805599453, 1.3862943611198906, 1.6094379124341003])
$

2
subjects/handling/README.md

@ -19,7 +19,7 @@ In case something goes wrong, it should panic, with the error.
### Expected Function
```rust
pub fn open_or_create(s: &str, content: &str) {
pub fn open_or_create(file: &str, content: &str) {
}
```

2
subjects/hashing/README.md

@ -6,7 +6,7 @@ Given a list of integers (Vec<i32>) write three **functions**.
Write a **function** called `mean` that calculates the `mean` (the average value) of all the values in the list.
Write a **function** called `median` that calculates the `median` (for a sorted list, it is the value in the middle).
Write a **function** called `median` that calculates the `median` (for a sorted list, it is the value in the middle). If there is an even amount of numbers in the list, the middle pair must be determined, added together, and divided by two to find the median value.
Write a **function** called `mode` that calculates the mode (the value
that appears more often).

4
subjects/looping/README.md

@ -4,7 +4,7 @@
Write a **program** that prints a riddle, receives input from the user and checks that the answer is correct.
The program must allow indefinite number of trials and only quit after the correct answer is given.
The program must allow an indefinite number of trials and only quit after the correct answer is given.
Every time the user introduces an incorrect answer the program must print the riddle again and after the user gives the correct answer the program must print the number of tries that took to get the correct answer.
@ -17,7 +17,7 @@ Answer: The letter e
- [Moduler std::io](https://doc.rust-lang.org/std/io/index.html)
- [loop](https://doc.rust-lang.org/std/keyword.loop.html)
### Usage
### Usage 
```console
$ cargo run

8
subjects/panic/README.md

@ -5,8 +5,6 @@
Write a **function** that tries to open a file and panics if the file
does not exist.
### Notions
### Expected Function
```rust
@ -27,9 +25,14 @@ use panic::*;
fn main() {
let filename = "created.txt";
File::create(filename).unwrap();
let a = open_file(filename);
println!("{:?}", a);
fs::remove_file(filename).unwrap();
//It must panic
let b = open_file(filename);
}
```
@ -38,5 +41,6 @@ And its output:
```console
$ cargo run
File { fd: 3, path: "panic/a.txt", read: true, write: false }
thread 'main' panicked at 'File not found'
$
```

2
subjects/profanity_filter/README.md

@ -18,7 +18,7 @@ The `struct` must also have an implementation of 2 **functions** associated with
- `send_ms`, which only has its implementation type (**self**) as argument and returns an option:
- This function must return `None` if the content of the message is either **empty** or contains the word **stupid**. Otherwise it returns the content of the message.
You will have to create two more **functions** that are not associated with any structure:
You will have to create one more **function** that is not associated with any structure:
- `check_ms` which:
- receives as parameters the reference to the structure `Message`

6
subjects/tuples/README.md

@ -4,7 +4,7 @@
- Define a tuple structure to represent a `Student`.
- Each student is identified by an id number of type i32, his/her name and his/her last name as a string Print the content of the tuple to stdout
- Each student is identified by an id number of type i32, his/her name and his/her last name of type string.
- Then define three **functions** to return the id, first name and last name.
@ -22,6 +22,10 @@
- [Chapter 7](https://doc.rust-lang.org/stable/book/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html)
### Dependencies
meval = "0.2"
### Expected Functions
```rust

Loading…
Cancel
Save