diff options
| author | bors <bors@rust-lang.org> | 2019-06-07 18:26:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-06-07 18:26:15 +0000 |
| commit | d132f544f9d74e3cc047ef211e57eae60b78e5c5 (patch) | |
| tree | 791d2fe11b49b7a14bba265fb1cdb41629e81282 /src/liballoc | |
| parent | c8865d8e195813ade6b84434ac9f8850e7112d1a (diff) | |
| parent | 5a01b547078e45cc1a96a062334d8571f129ddc2 (diff) | |
| download | rust-d132f544f9d74e3cc047ef211e57eae60b78e5c5.tar.gz rust-d132f544f9d74e3cc047ef211e57eae60b78e5c5.zip | |
Auto merge of #61130 - jonhoo:mem-take, r=SimonSapin
Add std::mem::take as suggested in #61129 This PR implements #61129 by adding `std::mem::take`. The added function is equivalent to: ```rust std::mem::replace(dest, Default::default()) ``` This particular pattern is fairly common, especially when implementing `Future::poll`, where you often need to yield an owned value in `Async::Ready`. This change allows you to write ```rust return Async::Ready(std::mem::take(self.result)); ``` instead of ```rust return Async::Ready(std::mem::replace(self.result, Vec::new())); ``` EDIT: Changed name from `take` to `swap_default`. EDIT: Changed name back to `take`.
Diffstat (limited to 'src/liballoc')
0 files changed, 0 insertions, 0 deletions
