refactor
This commit is contained in:
parent
3837ae8aef
commit
c555a0b664
1 changed files with 2 additions and 2 deletions
|
@ -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
|
- Reference `&T`: You have a read only reference of the variables content
|
||||||
- Mutable Reference `&mut T`: You have a modifiable reference to the variable
|
- 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
|
||||||
Conditionals like `if` and `match` can be used, while `match` can do more powerful pattern matching than `if`.
|
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"
|
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 {
|
if let StatusCode::Err(msg) = err_response {
|
||||||
println!("{msg}!");
|
println!("{msg}!");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue