diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2016-02-02 11:15:45 -0500 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2016-02-02 11:15:45 -0500 |
| commit | 6c907212b446e1c39ddb6db621bb72c6d07255f6 (patch) | |
| tree | 6ea0bad7814e8e182e88456848cce260b14c95ce | |
| parent | dc3a39d807512c626495c16680df2fffc16e8722 (diff) | |
Add note about temporaries
| -rw-r--r-- | src/doc/book/patterns.md | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/doc/book/patterns.md b/src/doc/book/patterns.md index 39a9cb1885e..6fd7f4cd475 100644 --- a/src/doc/book/patterns.md +++ b/src/doc/book/patterns.md @@ -196,8 +196,16 @@ let (x, _) = tuple; println!("Tuple is: {:?}", tuple); ``` -In a similar fashion to `_`, you can use `..` in a pattern to disregard -multiple values: +This also means that any temporary variables will be dropped at the end of the +statement: + +```rust +// Here, the String created will be dropped immediately, as it’s not bound: + +let _ = String::from(" hello ").trim(); +``` + +You can also use `..` in a pattern to disregard multiple values: ```rust enum OptionalTuple { |
