mirror of
https://github.com/m-lamonaca/dev-notes.git
synced 2025-04-06 10:56:41 +00:00
rust: borrowing in match statement
This commit is contained in:
parent
12fd8e7ff1
commit
30dec31a68
1 changed files with 1 additions and 0 deletions
|
@ -288,6 +288,7 @@ if let <pattern> = <value> {
|
||||||
let optional = Some(value);
|
let optional = Some(value);
|
||||||
match optional {
|
match optional {
|
||||||
Some(param) => { /* do something */ },
|
Some(param) => { /* do something */ },
|
||||||
|
Some(ref param) => { /* borrow value instead of moving */ }
|
||||||
_ => {},
|
_ => {},
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
Loading…
Add table
Reference in a new issue