This commit is contained in:
JMARyA 2023-12-27 07:53:37 +01:00
parent 3837ae8aef
commit c555a0b664
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -71,7 +71,7 @@ Rust enforces some rules on variables in order to be memory safe. So there are t
- Reference `&T`: You have a read only reference of the variables content
- Mutable Reference `&mut T`: You have a modifiable reference to the variable
> Note: If the function does not need to mutate or own a variable, consider using a reference
> Note: If a function does not need to mutate or own a variable, consider using a reference
### Conditionals
Conditionals like `if` and `match` can be used, while `match` can do more powerful pattern matching than `if`.
@ -140,7 +140,7 @@ match err_response {
StatusCode::Err(err) => println!("Some error: {err}"); // will print "Some error: Internal Error"
}
/// other way to pattern match for a single pattern
// other way to pattern match for a single pattern
if let StatusCode::Err(msg) = err_response {
println!("{msg}!");
}