Commit Graph

21 Commits

Author SHA1 Message Date
i509VCB 7c85b93627 add try_ functions for fallible heap growth (#158)
* add try_ functions for fallible heap growth

* tests for try_ functions
2022-04-20 12:43:34 -06:00
Eric Ridge 750f684d4f Issue #151: impl std::io::Write for u8-based TinyVecs (#152)
* impl std::io::Write for u8-based TinyVec

* undo bad formatting

* fix formatting
2021-09-24 11:58:46 -06:00
Soveu 35082e1d15 TinyVec::fmt - fix pretty printing (#138)
* TinyVec::fmt - fix pretty printing

* ArrayVec::fmt - fix pretty printing
2021-03-24 11:55:02 -06:00
SlightlyOutOfPhase 0529972454 Implement [value; N] syntax support for array_vec! (#118)
* Implement `[value; N]` syntax for `array_vec!`

Also implement the `($array_type:ty)` form by just calling `default()` immediately, which makes more sense.

* Add tests for `[value; N]` macro form

* Implement `[value; N]` syntax for `tiny_vec!`

Also make the same improvement to the `($array_type:ty)` macro variant that I did for `array_vec!`.

* Add tests for `[value; N]` macro form
2020-10-11 18:42:51 -06:00
aspen 686f424212 Add Serde support (#110)
* Add Serde support.

* Removes `serde/alloc` from deps( tests still pass without it anyways)

* Fix some issues that could result in a panic.

* Wait, actually use the size_hint properly.

* Error instead of silent truncation.

* That wasn't meant to be a default feature.
2020-08-17 07:39:29 -06:00
Benjamin Scherer 689cc12a11 Add ArrayVec::splice and TinyVec::splice (#85)
* Add ArrayVec::splice and TinyVec::splice

Added for closer API parity with std::Vec

* Fix ArrayVec::splice example typo

* Removed FusedIterator bound from splice

This bound could've caused confusing error messages, and was
inconsistent with the Vec API. splice now uses fuse itself to ensure
consistency. Vec::splice consumes the whole iterator at once, so it
essentially has the same behavior, but this implementation gradually
consumes the iterator as elements are drained, so this fuse is necessary
to keep the behavior the same.

* Reserve additional capacity in TinyVecSplice

Used TinyVec::reserve to pre-allocate space for elements being spliced
into the TinyVec after the splicing iterator is dropped. Used the lower
bound like Vec's splice does.

* Run rustfmt
2020-07-18 00:22:59 -06:00
Soveu 3919d5e804 "try_*" functions and "to_vec" for arrayvec (#82)
* change behavior on extend_from_slice, append

* preallocation in extend()

* append v2

* obviously

* fix resize_with

* try_functions and to_vec on arrayvec

* shrink_to_fit

* bit of cleaning

* cosmetic changes

* use asserts instead of if-panics

* I promise, this is the last commit

* examples, tests

* matches macro exists since rust 1.42

* Update tinyvec.rs

* new extend and insert

* mem::take is from rust 1.40
2020-07-17 16:07:10 -06:00
Soveu 1bfc9c0479 Pre-allocate memory in extend_from_slice, extend and append functions (#80)
* change behavior on extend_from_slice, append

* preallocation in extend()

* append v2

* obviously

* fix resize_with
2020-07-17 10:21:06 -06:00
Lokathor b8771760cc Closes https://github.com/Lokathor/tinyvec/issues/75 (#77)
* Closes https://github.com/Lokathor/tinyvec/issues/75

* This is a breaking change to the macro

* benchmarks fixes.

* slim down to just `take`
2020-07-03 10:56:45 -06:00
Benjamin Scherer 0fdcd0b4db Modify tiny_vec! to avoid error on non-Copy types (#74)
* Modify tiny_vec! to avoid error on non-Copy types

Using $elem in two closures in the previous version of the macro created
errors when using types that don't implement Copy. Moving the decision
of whether to allocate or use an inline array to the macro invocation
resolves this error as the borrow checker can see that both branches are
never taken together.

* Add test for tiny_vec! using non-Copy types

* Fix inference issue

* Use full crate path in tiny_vec!
2020-06-18 09:22:21 -06:00
Lokathor 3beff97fa6 Add the SliceVec type (#68)
* start of slicevec

* remove todo! because it's not in 1.36

* Update Cargo.toml

* slice vec into iterator

* slicevec drain

* complete last unimplemented

* remove the extra default feature

* spelling

* Update src/slicevec.rs

Co-Authored-By: Joshua Nelson <joshua@yottadb.com>

* docs clarification.

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-04-22 12:31:56 -06:00
Evgeny Rozaliev e0a598fb34 TinyVec::from([T]) (#66) 2020-03-17 14:15:39 -06:00
Wesley Norris 0dababa9fe Add TinyVec::from(slice) test 2020-01-24 08:24:44 -05:00
Lokathor 641590223e cargo fmt hasn't been used in a while it seems. 2020-01-19 13:02:54 -07:00
mental 73a5050f0d Account for heap capacity in capacity unit test 2020-01-19 05:07:35 +00:00
mental f5de23493b Account for heap allocated capacities. 2020-01-19 04:57:34 +00:00
Lokathor d3b27fa49c docs and rename the feature to alloc
Closes https://github.com/Lokathor/tinyvec/issues/18
We could discuss the "goals" section more of course, but for now it's enough to call that issue closed.
2020-01-13 19:55:38 -07:00
Lokathor 93ff65b237 Merge pull request #16 from Nemo157/fix-resize
Fix TinyVec::resize across inline/heap boundary
2020-01-13 18:49:19 -07:00
Wim Looman 3335c63092 Fix TinyVec::resize across inline/heap boundary 2020-01-13 20:21:46 +01:00
Wim Looman 71ad62a90f Fix ArrayishVec::swap_remove for last element 2020-01-13 19:42:49 +01:00
Wim Looman 95c991d6b4 Fix TinyVec::drain implementation 2020-01-12 14:07:19 +01:00