Commit Graph

112 Commits

Author SHA1 Message Date
bluss 602e55dc67 FEAT: Use drop_in_place for truncate and clear (and drop)
This should perform better in both release and debug mode.

NOTE: This is significant because it changes the drop order of the
elements, and how we handle panicking destructors. If just one of the
destructors panic during ArrayVec drop, clear or truncate, the rest of
the elements should still drop. If we encounter another panic during
that process, however, Rust will abort as usual for panic during
unwinding.
2018-03-25 23:26:20 +02:00
bluss 16aabf7c2c DOC: Fix typo in insert doc 2018-02-10 21:57:36 +01:00
bluss c1b72500cd REFAC Use clone_from_slice, extend in ArrayVec::clone_from
This is just a cleanup of the code, with less repetition.
2018-02-06 19:29:15 +01:00
bluss 2eeed4bae5 Merge pull request #90 from jeehoonkang/rust-1.12.1
Support Rust 1.13.0
2018-01-17 20:35:36 +01:00
bluss a903e1a770 FIX: Fix future compat warning with pointer casts
```
warning: the type of this value must be known in this context
   --> src/lib.rs:312:32
    |
312 |                 ptr::copy(p, p.offset(1), len - index);
    |                                ^^^^^^
    |
    = note: #[warn(tyvar_behind_raw_pointer)] on by default
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #46906 <https://github.com/rust-lang/rust/issues/46906>
```
2018-01-17 20:25:47 +01:00
Jeehoon Kang 3df64ccd50 Support Rust 1.13.0 2018-01-16 15:04:45 +09:00
bluss ef133ef960 FIX: Use drop_in_place in IntoIter's drop. 2017-12-03 21:57:38 +01:00
bluss a2e3fcea3f DOC: Minor fixes in docs, for ' → ’ 2017-10-27 22:54:46 +02:00
bluss 456aeaf557 FEAT: Remove odds dependency in arrayvec
Copy the encode_utf8 function from odds. std encode_utf8 requires Rust
1.15 and has a different signature, this one seems to fit us better.
2017-10-27 22:31:49 +02:00
bluss 895d450366 DOC: Promise debug assertions for unsafe methods
Instead of being vague about it, we can promise it.

We continue to be a bit vague in ArrayString::set_len.  I don't see how
to add a char boundary check in ArrayString::set_len unfortunately.

It's a tricky issue, checking char boundaries requires reading the
memory of the string, and we don't even know if the user of set_len has
initialized that area of memory yet (but they hopefully did).
2017-10-26 19:27:47 +02:00
Niklas Fiekas 5257cbd2b4 Add ArrayVec::truncate() 2017-10-18 18:14:07 +02:00
bluss ace20a9f43 DOC: Add docs for default values 2017-10-16 22:45:27 +02:00
bluss ac64b5b661 BUG: Fix "unused unsafe block" warning
This warning was only visible on stable, not nightly, which seems like
a bug.
2017-10-08 18:15:05 +02:00
bluss 793ad30be9 FEAT: Improve .extend() performance
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%
```
2017-10-08 17:44:06 +02:00
bluss 9825e58061 FEAT: Add CapacityError::new 2017-09-24 18:07:12 +02:00
bluss f33c4e44dd DOC: Mention serde-1 feature 2017-09-11 19:43:54 +02:00
bluss cea481f494 0.4.0 2017-08-08 21:07:02 +02:00
bluss 878fef8d8a MAINT: Require Rust 1.14 2017-08-06 21:07:51 +02:00
bluss b2b377117a DOC: Update doc for and disclaimers for crate features 2017-08-06 18:32:08 +02:00
bluss 6ea8e8c0bf DOC: Update root crate url 2017-08-06 18:32:08 +02:00
bluss 696459db27 DOC: Fix typo in doc comment 2017-08-06 00:37:33 +02:00
bluss 689e55b61d DOC: Use ArrayVec in doc for drain 2017-08-05 18:29:28 +02:00
bluss 4c90dc782d DOC: Copyedit the docs a bit 2017-08-05 18:22:21 +02:00
bluss 313ebe8335 FEAT: Rename .remove_opt() to .pop_at() 2017-08-05 18:22:06 +02:00
bluss 27b8a0cb0c BUG: Make error module private again 2017-08-05 18:06:56 +02:00
bluss 6ad4ca7a77 MAINT: Rust version Rust 1.15 2017-08-05 18:04:14 +02:00
bluss c5e0b80f73 FEAT: Turn try_remove/try_swap_remove into remove_opt and swap_pop
We turn these into "checked" removals, similar to `.pop()`. Name
swap_pop seems straightforward and nice, remove_opt is not as certain.
2017-08-05 17:52:24 +02:00
bluss bc9e0362bd FEAT: Remove InsertError again
try_insert has a capacity error, but panics if the index is out of
bounds.
2017-08-05 17:40:12 +02:00
bluss 345dd33942 FEAT: Refactor errors. Insert is either out of bounds or capacity error 2017-07-30 15:12:03 +02:00
bluss 4d7887010e DOC: Update docs for debug assertions 2017-07-30 14:33:49 +02:00
bluss a59b5c0b86 DOC: Rust version in docs
Required rust version should be in rustdoc

Reason: Written in one or a few places. Information is versioned with
the crate on docs.rs
2017-07-30 14:14:25 +02:00
bluss 1d08021107 BUG: Fix serde code for push change 2017-07-30 14:12:24 +02:00
bluss da62042001 FEAT: Make swap_remove return the element, add try_swap_remove for fallible 2017-07-30 13:18:50 +02:00
bluss 98af43cf9c FEAT: Make .push() use panics for errors, add .try_push() 2017-07-30 13:14:22 +02:00
bluss dadeedb787 FEAT: Proper Error impls for errors
Also use pub(crate), requiring Rust 1.18
2017-07-30 13:13:52 +02:00
bluss 79ccdcd910 FEAT: Copy RangeArgument from crate odds
This means odds is no longer a public dependency, which simplifies the
version story for arrayvec
2017-07-30 13:00:53 +02:00
bluss 5dcb5ab2c7 FEAT: Change .insert() and .remove() to match Vec
- Add try_insert / try_remove to be the old fallible variants that
  return errors
- Insert that pushes out if full does no longer exist -- full vec is an
  error
2017-07-30 12:57:28 +02:00
bluss 29497206da Merge pull request #55 from daboross/serde
Add serde support
2017-07-30 12:15:38 +02:00
David Ross 704f237282 Remove ambiguities in serde expecting messages. 2017-06-14 21:55:57 -07:00
David Ross 1b0168bb6f Change feature name from 'serde' to 'serde-1'. 2017-06-08 12:02:21 -07:00
David Ross 21cd20ff26 Add 'serde' feature for serializing and deserializing ArrayVec and ArrayString.
This implements serde support under the optional 'serde' feature, and adds unit tests to test said support.
https://serde.rs/unit-testing.html used as a guide for the unit tests - using 'serde_test' makes for much
less boilerplate here, but it does require that the project have a non-optional dev dependency on 'serde_test'.
2017-06-08 01:42:34 -07:00
Niklas Fiekas 12eee0677c Debug assert capacity in push_unchecked() 2017-05-24 21:16:27 +02:00
Niklas Fiekas 1b6e0a3bfb Use push_unchecked() for Extend 2017-05-13 23:51:17 +02:00
Niklas Fiekas d0ebfcd51f Factor out push_unchecked() 2017-05-13 23:51:17 +02:00
bluss f65ea92da4 Remove the optional generic-array feature
- It can be added back later if needed
- A public dependency implies version coupling, and we can't afford to
  have it for a niche use case.
2017-03-24 18:57:39 +01:00
bluss 3d69403dee Use encode_utf8 from crate odds 2016-10-16 11:54:44 +02:00
bluss d43c959fa8 0.3.20 2016-10-04 14:47:14 +02:00
bluss 7a7ec178b9 Fix ArrayString to implement .push(char) faster
Previously we used formatting, which is a virtual call and quite the
detour. Now copy the utf-8 encoding code from Rust (thank you Alex
Crichton) and use that.
2016-10-04 14:40:33 +02:00
bluss f331bb1228 0.3.19 2016-09-28 11:13:15 +02:00
bluss 60a97632bc Support generic-array as arrayvec backend 2016-09-28 11:06:20 +02:00