| Age | Commit message (Collapse) | Author | Lines | |
|---|---|---|---|---|
| 2021-02-02 | Auto merge of #79015 - WaffleLapkin:vec_append_from_within, r=KodrAus | bors | -4/+109 | |
| add `Vec::extend_from_within` method under `vec_extend_from_within` feature gate Implement <https://github.com/rust-lang/rfcs/pull/2714> ### tl;dr This PR adds a `extend_from_within` method to `Vec` which allows copying elements from a range to the end: ```rust #![feature(vec_extend_from_within)] let mut vec = vec![0, 1, 2, 3, 4]; vec.extend_from_within(2..); assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4]); vec.extend_from_within(..2); assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4, 0, 1]); vec.extend_from_within(4..8); assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4, 0, 1, 4, 2, 3, 4]); ``` ### Implementation notes Originally I've copied `@Shnatsel's` [implementation](https://github.com/WanzenBug/rle-decode-helper/blob/690742a0de158d391b7bde1a0c71cccfdad33ab3/src/lib.rs#L74) with some minor changes to support other ranges: ```rust pub fn append_from_within<R>(&mut self, src: R) where T: Copy, R: RangeBounds<usize>, { let len = self.len(); let Range { start, end } = src.assert_len(len);; let count = end - start; self.reserve(count); unsafe { // This is safe because `reserve()` above succeeded, // so `self.len() + count` did not overflow usize ptr::copy_nonoverlapping( self.get_unchecked(src.start), self.as_mut_ptr().add(len), count, ); self.set_len(len + count); } } ``` But then I've realized that this duplicates most of the code from (private) `Vec::append_elements`, so I've used it instead. Then I've applied `@KodrAus` suggestions from https://github.com/rust-lang/rust/pull/79015#issuecomment-727200852. | ||||
| 2021-02-02 | update tracking issue for vec_extend_from_within | Ashley Mannix | -1/+1 | |
| 2021-01-31 | add `Vec::extend_from_within` method | Waffle | -4/+109 | |
| Implement <https://github.com/rust-lang/rfcs/pull/2714>, changes from the RFC: - Rename the method `append_from_within` => `extend_from_within` - Loose :Copy bound => :Clone - Specialize in case of :Copy This commit also adds `Vec::split_at_spare` private method and use it to implement `Vec::spare_capacity_mut` and `Vec::extend_from_within`. This method returns 2 slices - initialized elements (same as `&mut vec[..]`) and uninitialized but allocated space (same as `vec.spare_capacity_mut()`). | ||||
| 2021-01-29 | Updated Vec::splice documentation | Chan Kwan Yin | -1/+1 | |
| Replacing with equal number of values does not increase the length of the vec. Reference: https://stackoverflow.com/a/62559271/3990767 | ||||
| 2021-01-26 | shrink_to shouldn't panic on len greater than capacity | Thom Wiggers | -6/+6 | |
| 2021-01-22 | Add doc aliases for memory allocations | Yoshua Wuyts | -0/+7 | |
| - Vec::with_capacity / Box::new -> alloc + malloc - Box::new_zeroed -> calloc - Vec::{reserve,reserve_exact,try_reserve_exact,shrink_to_fit,shrink_to} -> realloc | ||||
| 2021-01-21 | Remove link to current section | Ivan Tham | -2/+1 | |
| Co-authored-by: Mara Bos <m-ou.se@m-ou.se> | ||||
| 2021-01-20 | Add more details explaning the Vec visualization | Ivan Tham | -20/+22 | |
| Suggested by oli-obk | ||||
| 2021-01-20 | Add Vec visualization to understand capacity | Ivan Tham | -0/+21 | |
| Visualize vector while differentiating between stack and heap. Inspired by cheats.rs, as this is probably the first place beginner go, they could understand stack and heap, length and capacity with this. Not sure if adding this means we should add to other places too. Superseeds #76066 | ||||
| 2021-01-14 | Rollup merge of #80972 - KodrAus:deprecate/remove_item, r=nagisa | Mara Bos | -21/+0 | |
| Remove unstable deprecated Vec::remove_item Closes #40062 The `Vec::remove_item` method was deprecated in `1.46.0` (in August of 2020). This PR now removes that unstable method entirely. | ||||
| 2021-01-13 | remove unstable deprecated Vec::remove_item | Ashley Mannix | -21/+0 | |
| 2021-01-09 | Add comment to `Vec::truncate` explaining `>` vs `>=` | Camelid | -0/+3 | |
| Hopefully this will prevent people from continuing to ask about this over and over again :) See [this Zulip discussion][1] for more. [1]: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Vec.3A.3Atruncate.20implementation | ||||
| 2020-12-29 | style: applying Rust style | C | -2/+2 | |
| 2020-12-29 | refactor: removing // ignore-tidy-filelength | C | -1/+0 | |
| 2020-12-29 | refactor: moved SpecExtend into spec_extend.rs | C | -79/+5 | |
| 2020-12-29 | refactor: moving SpecFromIter into spec_from_iter.rs | C | -92/+4 | |
| 2020-12-29 | refactor: moved SpecFromIterNested to spec_from_iter_nested.rs | C | -52/+4 | |
| 2020-12-29 | refactor: moved InPlaceDrop into in_place_drop.rs | C | -22/+4 | |
| 2020-12-29 | refactor: moved SetLenOnDrop to set_len_on_drop | C | -29/+4 | |
| 2020-12-29 | refactor: moved SpecFromElem to spec_from_elem.rs | C | -55/+4 | |
| 2020-12-29 | refactor: moved PartialEq into partial_eq | C | -39/+2 | |
| 2020-12-29 | refactor: moving SourceIterMarker into source_iter_marker.rs | C | -104/+3 | |
| 2020-12-29 | refactor: moved IsZero into is_zero.rs | C | -70/+4 | |
| 2020-12-29 | refactor: moving AsIntoIter into into_iter.rs | C | -15/+1 | |
| 2020-12-29 | refactor: moved IntoIter into into_iter.rs | C | -264/+6 | |
| 2020-12-29 | refactor: moved Vec impl Cow into cow.rs | C | -35/+2 | |
| 2020-12-29 | refactor: moving Drain into drain.rs | C | -147/+5 | |
| 2020-12-29 | refactor: moving Splice into splice.rs | C | -128/+5 | |
| 2020-12-29 | refactor: moving DrainFilter into drain_filter.rs | C | -138/+5 | |
| 2020-12-29 | refactor: moving vec.rs to vec/mod.rs | C | -0/+3725 | |
