diff options
| author | bors <bors@rust-lang.org> | 2015-04-28 22:13:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-04-28 22:13:42 +0000 |
| commit | 8871c17b76a1e0ab36ce2bb51008b53f596e5b3c (patch) | |
| tree | 5c1266423c1dd3e9a7728303a96b42636402e9e4 /src/libstd/lib.rs | |
| parent | cadc67e8fd942e0a3896ed0d5375444b221e60d7 (diff) | |
| parent | b475fc7d6aa1cafa91790c273908fddfb669a82e (diff) | |
| download | rust-8871c17b76a1e0ab36ce2bb51008b53f596e5b3c.tar.gz rust-8871c17b76a1e0ab36ce2bb51008b53f596e5b3c.zip | |
Auto merge of #24781 - bluss:vec-drain-range, r=alexcrichton
Implement Vec::drain(\<range type\>) from rust-lang/rfcs#574, tracking issue #23055. This is a big step forward for vector usability. This is an introduction of an API for removing a range of *m* consecutive elements from a vector, as efficently as possible. New features: - Introduce trait `std::collections::range::RangeArgument` implemented by all four built-in range types. - Change `Vec::drain()` to use `Vec::drain<R: RangeArgument>(R)` Implementation notes: - Use @Gankro's idea for memory safety: Use `set_len` on the source vector when creating the iterator, to make sure that the part of the vector that will be modified is unreachable. Fix up things in Drain's destructor — but even if it doesn't run, we don't expose any moved-out-from slots of the vector. - This `.drain<R>(R)` very close to how it is specified in the RFC. - Introduced as unstable - Drain reuses the slice iterator — copying and pasting the same iterator pointer arithmetic again felt very bad - The `usize` index as a range argument in the RFC is not included. The ranges trait would have to change to accomodate it. Please help me with: - Name and location of the new ranges trait. - Design of the ranges trait - Understanding Niko's comments about variance (Note: for a long time I was using a straight up &mut Vec in the iterator, but I changed this to permit reusing the slice iterator). Previous PR and discussion: #23071
Diffstat (limited to 'src/libstd/lib.rs')
0 files changed, 0 insertions, 0 deletions
