Uses old Rust 2015
|1.0.1||Oct 11, 2019|
|1.0.0||Aug 27, 2018|
#365 in Algorithms
101 downloads per month
Used in 8 crates (via total-order-multi-map)
Vec::drain_filter implementation, slightly diverging from
the std's implementation.
This crate provides an extension trait adding a
e_ prefix is used to prevent name collisions with std as the
drain_filter might be stabilized as
e_drain_where as one large difference to drain filter. It doesn't
run to completion when dropped and can as such be "early stopped" from
the outside by stopping the iteration an dropping the iterator.
The reason why
Vec::drain_filter does run the drain to completion
on drop is that it can be quite confusing. E.g. the code:
Would not necessary do what it's expected to do, i.e. it would drain
thinks until it finds any drained value with
had_fatal_error() == true
and then would stop draining (with
But running to completion on drop is also tricky/dangerous e.g. it can
lead easily to thinks like panic's on drop and as such double panics,
while drop on panic behavior for
Vec::drain_filter might still change
before stabilization, this crate completely avoids the problem at cost
of making it easy to accidentally stop the draining to early.
Documentation can be viewed on docs.rs. (at least once it's published ;=) )
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.