793ad30be9ff71a134848308e819f3fb706f1fe2
We have to use the "SetLenOnDrop" pattern (see stdlib Vec) here. Keep the length in a separate variable, write it back on scope exit. To help the compiler with alias analysis and stuff. We update the length to handle panic in the iteration of the user's iterator, without dropping any elements on the floor. Note: This code was tested without the scope guard using the new option -Zmutable-noalias, which had no effect here. benchmark: ``` name before.txt ns/iter after.txt ns/iter diff ns/iter diff % extend_with_constant 280 (1828 MB/s) 74 (6918 MB/s) -206 -73.57% extend_with_range 1,285 (398 MB/s) 979 (522 MB/s) -306 -23.81% extend_with_slice 29 (17655 MB/s) 14 (36571 MB/s) -15 -51.72% ```
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
arrayvec
========
A vector with fixed capacity.
Please read the `API documentation here`__
__ https://docs.rs/arrayvec
|build_status|_ |crates|_ |crates2|_
.. |build_status| image:: https://travis-ci.org/bluss/arrayvec.svg
.. _build_status: https://travis-ci.org/bluss/arrayvec
.. |crates| image:: http://meritbadge.herokuapp.com/arrayvec
.. _crates: https://crates.io/crates/arrayvec
.. |crates2| image:: http://meritbadge.herokuapp.com/nodrop
.. _crates2: https://crates.io/crates/nodrop
Recent Changes (arrayvec)
-------------------------
- 0.4.2
- Add constructor method ``new`` to ``CapacityError``.
- 0.4.1
- Add ``Default`` impl to ``ArrayString`` by @tbu-
- 0.4.0
- Reformed signatures and error handling by @bluss and @tbu-:
- ``ArrayVec``'s ``push, insert, remove, swap_remove`` now match ``Vec``'s
corresponding signature and panic on capacity errors where applicable.
- Add fallible methods ``try_push, insert`` and checked methods
``pop_at, swap_pop``.
- Similar changes to ``ArrayString``'s push methods.
- Use a local version of the ``RangeArgument`` trait
- Add array sizes 50, 150, 200 by @daboross
- Support serde 1.0 by @daboross
- New method ``.push_unchecked()`` by @niklasf
- ``ArrayString`` implements ``PartialOrd, Ord`` by @tbu-
- Require Rust 1.14
- crate feature ``use_generic_array`` was dropped.
- 0.3.23
- Implement ``PartialOrd, Ord`` as well as ``PartialOrd<str>`` for
``ArrayString``.
- 0.3.22
- Implement ``Array`` for the 65536 size
- 0.3.21
- Use ``encode_utf8`` from crate odds
- Add constructor ``ArrayString::from_byte_string``
- 0.3.20
- Simplify and speed up ``ArrayString``’s ``.push(char)``-
- 0.3.19
- Add new crate feature ``use_generic_array`` which allows using their
``GenericArray`` just like a regular fixed size array for the storage
of an ``ArrayVec``.
- 0.3.18
- Fix bounds check in ``ArrayVec::insert``!
It would be buggy if ``self.len() < index < self.capacity()``. Take note of
the push out behavior specified in the docs.
- 0.3.17
- Added crate feature ``use_union`` which forwards to the nodrop crate feature
- Added methods ``.is_full()`` to ``ArrayVec`` and ``ArrayString``.
- 0.3.16
- Added method ``.retain()`` to ``ArrayVec``.
- Added methods ``.as_slice(), .as_mut_slice()`` to ``ArrayVec`` and ``.as_str()``
to ``ArrayString``.
- 0.3.15
- Add feature std, which you can opt out of to use ``no_std`` (requires Rust 1.6
to opt out).
- Implement ``Clone::clone_from`` for ArrayVec and ArrayString
- 0.3.14
- Add ``ArrayString::from(&str)``
- 0.3.13
- Added ``DerefMut`` impl for ``ArrayString``.
- Added method ``.simplify()`` to drop the element for ``CapacityError``.
- Added method ``.dispose()`` to ``ArrayVec``
- 0.3.12
- Added ArrayString, a fixed capacity analogy of String
- 0.3.11
- Added trait impls Default, PartialOrd, Ord, Write for ArrayVec
- 0.3.10
- Go back to using external NoDrop, fixing a panic safety bug (issue #3)
- 0.3.8
- Inline the non-dropping logic to remove one drop flag in the
ArrayVec representation.
- 0.3.7
- Added method .into_inner()
- Added unsafe method .set_len()
Recent Changes (nodrop)
-----------------------
- 0.1.9
- Fix issue in recent nightly where ``repr(u8)`` did not work. Use
a better way to get rid of the enum layout optimization.
- 0.1.8
- Add crate feature ``use_union`` that uses untagged unions to implement NoDrop.
Finally we have an implementation without hacks, without a runtime flag,
and without an actual ``Drop`` impl (which was needed to suppress drop).
The crate feature requires nightly and is unstable.
- 0.1.7
- Remove crate feature ``no_drop_flag``, because it doesn't compile on nightly
anymore. Drop flags are gone anyway!
- 0.1.6
- Add feature std, which you can opt out of to use ``no_std``.
- 0.1.5
- Added crate feature ``use_needs_drop`` which is a nightly-only
optimization, which skips overwriting if the inner value does not need
drop.
Recent Changes (nodrop-union)
-----------------------
- 0.1.9
- Add ``Copy, Clone`` implementations
- 0.1.8
- Initial release
License
=======
Dual-licensed to be compatible with the Rust project.
Licensed under the Apache License, Version 2.0
http://www.apache.org/licenses/LICENSE-2.0 or the MIT license
http://opensource.org/licenses/MIT, at your
option. This file may not be copied, modified, or distributed
except according to those terms.
Description
Languages
Rust
100%