Commit Graph

31 Commits

Author SHA1 Message Date
bluss 2de36ba2ca Add 65536 to the Array impls 2017-08-06 18:44:48 +02:00
bluss 313ebe8335 FEAT: Rename .remove_opt() to .pop_at() 2017-08-05 18:22:06 +02:00
bluss cf76a83a7f BUG: Fix import of CapacityError in tests 2017-08-05 18:21:43 +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 1e83039426 FEAT: Align ArrayString .push and .push_str with String
Use same signatures (meaning: panics on errors). Add fallible versions
.try_push() and .try_push_str()
2017-07-30 15:38:42 +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 98af43cf9c FEAT: Make .push() use panics for errors, add .try_push() 2017-07-30 13:14:22 +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
bluss 28b2543ae0 Remove failing test (with optimizations)
What the test was doing was simply UB and we can't expect rustc to make
sense of it. The test was failing with optimizations on, yet a closer look
says arrayvec is still working as it should. So remove the broken test.
2017-07-29 12:38:50 +02:00
David Ross 6cd03dce8d Add failure tests for serde implementations
Thanks to @camlorn for the idea.
2017-06-16 15:09:48 -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
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 da459bcf78 Add constructor ArrayString::from_byte_string(b"abc")
This is an alternative constructor that never has capacity errors.
Unfortunately the error case is invalid UTF-8!
2016-12-14 15:01:17 +01: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 60a97632bc Support generic-array as arrayvec backend 2016-09-28 11:06:20 +02:00
bluss 2a1378d3eb Fix bounds checking in ArrayVec::insert(index, element)
Must be `index <= len && index < capacity`
2016-09-21 14:21:07 +02:00
bluss c5589aecdf Add .retain() method
Based on "retain_mut" as discussed for vec: we can provide &mut to the
element to remove effortlessly.
2016-02-18 00:34:40 +01:00
bluss a17c764f98 impl clone_from for ArrayVec and ArrayString 2016-02-06 15:22:27 +01:00
bluss 9fdb7dd631 Fixup indentation 2016-02-06 00:59:37 +01:00
Alexander Regueiro 0a413975f5 Re-added accidentally removed test method.
Also fixed indentation.
2016-02-05 22:56:44 +00:00
Alexander Regueiro 9845491060 Added ArrayString::from constructor that takes string slice.
Also added corresponding test.
2016-02-05 22:30:24 +00:00
bluss 62d372ce1f Add DerefMut for ArrayString 2016-01-13 13:01:13 +01:00
bluss c73d5fa203 Implement Error trait for CapacityError 2015-09-20 13:02:08 +02:00
bluss 6af588cb2c ArrayString: Add PartialEq, Eq, Hash, and tests 2015-09-18 00:52:17 +02:00
bluss def1be54ed Add test for Write 2015-09-10 19:49:37 +02:00
bluss c35760e02c Use NoDrop to fix panic safety issues
ArrayVec::drop was not panic safe — if there would be a panic during an
element's drop, the discriminant would never be set to Dropped, and the
array elements would potentially double drop.

Fix this by going back to the old NoDrop composition. The NoDrop struct
thas its own Drop impl, that will trigger too on panic during an element's
drop. This serves to make ArrayVec::drop panic safe.

Also tweak IntoIter::drop to make it panic safe: set inner ArrayVec's
length before dropping any elements.

Thank you to @Stebalien for reporting this bug and providing the
excellent testcases in this commit.

Using NoDrop expands ArrayVec to have two drop flags again, but this
is a temporary tradeoff, drop flags will eventually go away.

Fixes #3
2015-08-20 22:33:01 +02:00
root cf273fec1f Use a non-dropping enum directly
Don't use NoDrop as a separate abstraction: Then we have two drop flags,
one for ArrayVec and one for NoDrop. Instead import the logic from
NoDrop. The result is a much smaller ArrayVec value.
2015-07-30 16:14:04 +02:00
root 5c50c4dbc7 Add method .into_inner() 2015-06-22 16:35:21 +02:00
root 196a9d60b6 Move tests to tests/ directory 2015-05-25 02:35:52 +02:00