Commit Graph

16 Commits

Author SHA1 Message Date
Benjamin Scherer 04f65e50cf 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 af665296b5 "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 66077cfa99 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 5bb7c7585b 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 fb92d14ab4 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 c81bc9f0b1 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 5ba37a6b3a TinyVec::from([T]) (#66) 2020-03-17 14:15:39 -06:00
Wesley Norris 48905d9c43 Add TinyVec::from(slice) test 2020-01-24 08:24:44 -05:00
Lokathor 032ac155c9 cargo fmt hasn't been used in a while it seems. 2020-01-19 13:02:54 -07:00
mental 59257ad80f Account for heap capacity in capacity unit test 2020-01-19 05:07:35 +00:00
mental dd802b30fa Account for heap allocated capacities. 2020-01-19 04:57:34 +00:00
Lokathor 50b84c54b1 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 bc20225012 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 2049895f28 Fix TinyVec::resize across inline/heap boundary 2020-01-13 20:21:46 +01:00
Wim Looman cc6b7d4b46 Fix ArrayishVec::swap_remove for last element 2020-01-13 19:42:49 +01:00
Wim Looman 18300412ff Fix TinyVec::drain implementation 2020-01-12 14:07:19 +01:00