about summary refs log tree commit diff
path: root/src/liballoc/string.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-04-16 13:21:56 +0000
committerbors <bors@rust-lang.org>2018-04-16 13:21:56 +0000
commit1ef1563518d48ad9231b3ec3ac463d34d819ed28 (patch)
tree1fb05811590e2701a4d1875d9326261e655cfeec /src/liballoc/string.rs
parentd6a2dd9912e762fb0029c4463002d674686c1159 (diff)
parent5c58eec0bd8cee8fb2a191396d5ad5b5c9b0116a (diff)
downloadrust-1ef1563518d48ad9231b3ec3ac463d34d819ed28.tar.gz
rust-1ef1563518d48ad9231b3ec3ac463d34d819ed28.zip
Auto merge of #48945 - clarcharr:iter_exhaust, r=Kimundi
Replace manual iterator exhaust with for_each(drop)

This originally added a dedicated method, `Iterator::exhaust`, and has since been replaced with `for_each(drop)`, which is more idiomatic.

<del>This is just shorthand for `for _ in &mut self {}` or `while let Some(_) = self.next() {}`. This states the intent a lot more clearly than the identical code: run the iterator to completion.

<del>At least personally, my eyes tend to gloss over `for _ in &mut self {}` without fully paying attention to what it does; having a `Drop` implementation akin to:

<del>`for _ in &mut self {}; unsafe { free(self.ptr); }`</del>

<del>Is not as clear as:

<del>`self.exhaust(); unsafe { free(self.ptr); }`

<del>Additionally, I've seen debate over whether `while let Some(_) = self.next() {}` or `for _ in &mut self {}` is more clear, whereas `self.exhaust()` is clearer than both.
Diffstat (limited to 'src/liballoc/string.rs')
0 files changed, 0 insertions, 0 deletions