Commit Graph

110 Commits

Author SHA1 Message Date
Soveu f4cc761057 Make code DRYer (#107)
* make code dryer

* arrayset definition caused cargo fmt to fail
2020-08-09 10:52:06 -06:00
Soveu 52b17b84cd SliceVec fuzzer + overflow fix on usize::MAX ranges (#99)
* add slicevec fuzzer

* prevent overflow on range calculation
2020-08-09 10:45:19 -06:00
Lokathor 1196d2ae7c Add doc attributes for docs.rs build (#105)
* add with_capacity method.

* Improve docs.

* .

* name the correct requirements.
2020-08-09 10:30:17 -06:00
Lokathor 3ff291c63b alter docs. (#106) 2020-08-09 10:27:55 -06:00
Lokathor 8a47545150 Cratesio fix (#104)
* add with_capacity method.

* Improve docs.
2020-08-09 09:13:26 -06:00
Lokathor 5d40a3f92c add with_capacity method. (#103) 2020-08-08 19:49:31 -06:00
Lokathor 1f2178925c more fn attributes. 2020-08-08 19:09:18 -06:00
Lokathor 72ac150239 Formally move the arrayset into a backup folder. It will become a separate crate some day. 2020-08-08 19:04:39 -06:00
Lokathor b0f27be4b7 apply some fn attributes. 2020-08-08 19:01:45 -06:00
Soveu 41abf04f28 Fuzz Fuzz Fuzz (#98)
* more features for fuzzing

* arrayveciter fuzzer + overflow fix

* moar fuzzers and tinyvecdrain change

* cargo fmt

* Self on enums is not stable in 1.36

* 🐞 BUGFIX: ArrayVecIterator::nth_back

* cargo fmt
2020-08-02 14:40:13 -06:00
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
Benjamin Scherer 478a8a0124 Make capacity() methods not rely on Array::CAPACITY (#83)
* Make capacity() methods not rely on Array::CAPACITY

Because Array isn't an unsafe trait, unsafe code cannot depend on the
length of a slice produced by Array::as_slice to be at least as long as
Array::CAPACITY. This means that unsafe code also cannot depend on
capacity() methods that return Array::CAPACITY. Returning the result of
a slice len() call ensures that if nothing else, with a sound
implementation of Array, capacity() methods will return a valid length
for a sub-slice of the backing array.

* Add comments explaining choice against using Array::CAPACITY
2020-07-15 21:02:26 -06:00
Lokathor e069cd2906 Relicense from Zlib to Zlib OR Apache-2.0 OR MIT (#81)
* rustfmt

* Replace crate description so Shnatsel doesn't need to sign off on the relicense.

* write more crate docs.
2020-07-15 06:45:39 -06:00
Lokathor d8420baa58 fix my own error 2020-07-03 21:45:55 -06:00
Lokathor 1415fd90f9 Update arrayset.rs 2020-07-03 21:34:57 -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
Diggory Hardy 726167b3a9 Implement ArraySet (#73) 2020-06-18 09:21:53 -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
Lokathor b94c08cd43 Update arrayvec.rs 2020-02-11 12:32:18 -07:00
Lokathor 695cc79635 Update arrayvec.rs 2020-02-11 12:15:19 -07:00
Lokathor cc55f669c4 Improve Write impl efficiency 2020-02-10 20:14:20 -07:00
Lokathor 574126f56b oops, dumb lifetimes. 2020-02-10 20:06:35 -07:00
Lokathor 3b06e8498c put in a highly experimental Write impl for ArrayVec of bytes 2020-02-10 20:02:56 -07:00
Lokathor 49a26a2bd5 Closes https://github.com/Lokathor/tinyvec/issues/48 2020-02-10 19:52:15 -07:00
dxenonb 47fd42eefd Fix typo 2020-02-06 20:57:22 -05:00
Wim Looman ac8dfa5cef Allow inferring array type for macro constructors 2020-01-28 12:51:35 +01:00
Wim Looman 45275fbbc2 Make macros work without any other imports 2020-01-28 12:46:39 +01:00
Wim Looman 5e46d949af Allow trailing comma in tiny_vec! 2020-01-28 12:43:32 +01:00
Lokathor 922aa16856 Merge pull request #57 from Lokathor/optimize-large-tiny_vec-macro-usage
Makes `tiny_vec!` go directly to the heap if the CAPACITY would have overflowed.
2020-01-26 14:56:30 -07:00
mgostIH a699b96036 Fixed links in documentation by removing ::<A> 2020-01-26 22:25:33 +01:00
Lokathor 8bb66c5676 Update tinyvec.rs 2020-01-26 14:20:40 -07:00
Lokathor 180cf57ce3 sigh 2020-01-26 13:53:13 -07:00
Lokathor f5d6afb5af clippy 2020-01-26 13:47:24 -07:00
Lokathor 9cd112fb8f Merge branch 'small-updates' of https://github.com/Lokathor/tinyvec into small-updates 2020-01-26 13:38:41 -07:00
Lokathor ddf66f2222 docs, and fix up tiny_vec macro 2020-01-26 13:38:38 -07:00
Lokathor 44373a53a2 Merge branch 'master' into small-updates 2020-01-26 13:37:57 -07:00
Lokathor d296cb65a6 Merge branch 'master' into small-updates 2020-01-26 12:44:18 -07:00
Lokathor d155790c50 Merge pull request #56 from mgostIH/drain
Added more efficient implementation for ArrayVecDrain
2020-01-26 12:39:16 -07:00
Lokathor c1ec9582ac Merge pull request #54 from Nemo157/intoiter-debug
impl Debug for {Tiny,Array}VecIterator
2020-01-26 12:38:00 -07:00
Lokathor 398b3e1072 Merge pull request #52 from Nemo157/refintoiter
impl IntoIterator for &[mut] TinyVec
2020-01-26 12:36:46 -07:00
mgostIH fbcc24e988 Added more efficient implementation for ArrayVecDrain, changed a few internal members of the struct, tests passed 2020-01-26 13:51:25 +01:00
Wim Looman 109e9b6e61 impl Debug for {Tiny,Array}VecIterator 2020-01-24 14:40:17 +01:00
Wim Looman a033772cbd impl IntoIterator for &[mut] TinyVec 2020-01-24 14:28:57 +01:00