Commit Graph

29 Commits

Author SHA1 Message Date
Soveu 78eac4ff84 Change len type from usize to u16 (#97)
* change len from usize to u16

* cargo fmt

* change len to tail
2020-07-31 13:46:05 -06:00
Soveu 820dbc4c85 A bit of everything for iterators (#87)
* slight changes functions that use drain

* bug in arrayvec iter

* reverse iter for arrayvec

* nth_back is stable since 1.37

* simpler drain for arrayvec

* soveu forgot to add changed files

* fmt + feature for rustc >= 1.40

* cosmetic changes

* does the ci work now?

* SHNAAAAAAAAATSEEEEEEEEL
2020-07-23 13:28:01 -06:00
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
Josh Stone d04abff44c impl IntoIterator for &/&mut ArrayVec (#69)
These just create slice iterators, but the impls are useful to have for
contexts that don't auto-deref, as in the new tests.
2020-03-31 13:36:39 -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
Andreas Molzer fd28ecb105 Test and fix removal at past-the-end index 2020-01-18 13:24:58 +01:00
Lokathor b2c3141a6a more docs, more renames, closer to being good. 2020-01-13 21:34:22 -07:00
Lokathor c74c1e3785 rename arrayish to array I guess
The "ish" part was always supposed to be temporary.
2020-01-13 21:12:04 -07: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
Wim Looman 5567e85dc7 Fix ArrayishVec::drain implementation
The end bound was off by one
2020-01-12 13:54:35 +01:00
Lokathor 56cdcb1d7e we're calling the ArrayishVec done for now I think 2020-01-09 22:17:14 -07:00
Lokathor e50dfd5a5a append 2020-01-09 00:39:34 -07:00
Lokathor 7e47b7132d Partial work on ArrayishVec 2020-01-07 23:10:38 -07:00
Lokathor c8bd5cc2b2 Try to adopt 1.24 as the CI version
This would allow our crate to be used as a dependency of the `unicode-segmentation` crate.
2020-01-06 20:28:09 -07:00
Lokathor c063024184 add truncate method and tests based on the Vec examples 2020-01-06 20:05:08 -07:00
Lokathor 76058032f5 base files 2020-01-06 19:29:40 -07:00