summary refs log tree commit diff
path: root/src/libcore/slice
AgeCommit message (Collapse)AuthorLines
2018-10-18Stabilize slice::rchunks(), rchunks_mut(), rchunks_exact(), rchunk_exact_mut()Sebastian Dröge-40/+32
Fixes #55177
2018-10-18Stabilize slice::chunks_exact() and slice::chunks_exact_mut()Sebastian Dröge-21/+17
Fixes #47115
2018-10-18Auto merge of #54580 - sdroege:rchunks, r=SimonSapinbors-33/+717
Add slice::rchunks(), rchunks_mut(), rchunks_exact() and rchunks_exact_mut() These work exactly like the normal chunks iterators but start creating chunks from the end of the slice. ---- The new iterators were motivated by a [comment](https://github.com/rust-lang/rust/issues/47115#issuecomment-424141121) by @DutchGhost. ~~~This currently includes the commits from https://github.com/rust-lang/rust/pull/54537 to not have to rename things twice or have merge conflicts. I'll force-push a new version of the branch ones those are in master.~~~ Also the stabilization tracking issue is just some number right now. I'll create the corresponding issue once this is reviewed and otherwise mergeable. cc @DutchGhost
2018-10-18Add slice::rchunks(), rchunks_mut(), rchunks_exact() and rchunks_exact_mut()Sebastian Dröge-33/+717
These work exactly like the normal chunks iterators but start creating chunks from the end of the slice. See #55177 for the tracking issue
2018-10-12Auto merge of #54534 - nagisa:align-offset-simplification, r=alexcrichtonbors-1/+1
Simplify implementation of align_offset slightly
2018-10-08Auto merge of #54700 - frewsxcv:frewsxcv-binary-search, r=GuillaumeGomezbors-10/+13
Clarify docs for when binary_search has many matches. Fixes https://github.com/rust-lang/rust/issues/51817.
2018-10-07Clarify docs for when binary_search has many matches.Corey Farwell-10/+13
Fixes https://github.com/rust-lang/rust/issues/51817.
2018-10-02Rollup merge of #54687 - scottmcm:more-elision, r=dtolnayPietro Albini-48/+48
Use impl_header_lifetime_elision in libcore The feature is approved for stabilization, so let's use it to remove about 300 `'a`s. Tracking issue for the feature: https://github.com/rust-lang/rust/issues/15872
2018-10-01Rollup merge of #53784 - tbu-:pr_doc_slice_isize_max, r=RalfJungkennytm-3/+14
Document that slices cannot be larger than `isize::MAX` bytes Fixes #53676.
2018-09-30Simplify implementation of align_offset slightlySimonas Kazlauskas-1/+1
2018-09-29Use impl_header_lifetime_elision in libcoreScott McMurray-48/+48
2018-09-29Revert "Auto merge of #53508 - japaric:maybe-uninit, r=RalfJung"Ralf Jung-10/+16
This reverts commit c6e3d7fa3113aaa64602507f39d4627c427742ff, reversing changes made to 4591a245c7eec9f70d668982b1383cd2a6854af5.
2018-09-27Don't have two adjacent "see also" sentencesTobias Bucher-3/+1
2018-09-25Rollup merge of #54537 - sdroege:chunks-exact, r=alexcrichtonPietro Albini-52/+52
Rename slice::exact_chunks() to slice::chunks_exact() See https://github.com/rust-lang/rust/issues/47115#issuecomment-403090815 and https://github.com/rust-lang/rust/issues/47115#issuecomment-424053547
2018-09-25Also rename ExactChunks iterator name to ChunksExactSebastian Dröge-25/+25
2018-09-24Rename slice::exact_chunks() to slice::chunks_exact()Sebastian Dröge-29/+29
See https://github.com/rust-lang/rust/issues/47115#issuecomment-403090815 and https://github.com/rust-lang/rust/issues/47115#issuecomment-424053547
2018-09-23Introduce the partition_dedup/by/by_key methods for slicesClément Renault-0/+172
2018-09-22address Mark-Simulacrum commentsJorge Aparicio-9/+6
2018-09-22core: fix deprecated warningsJorge Aparicio-13/+10
2018-09-22Rollup merge of #54422 - ljedrz:simplify_first_last, r=Mark-SimulacrumPietro Albini-6/+6
Simplify slice's first(_mut) and last(_mut) with get This change makes these functions easier to read and interpret. I haven't detected any difference in performance locally. r? @Mark-Simulacrum
2018-09-21Simplify slice's first(_mut) and last(_mut) with getljedrz-6/+6
2018-09-20define copy_within on slicesJack O'Connor-0/+57
This is a safe wrapper around ptr::copy, for regions within a single slice. Previously, safe in-place copying was only available as a side effect of Vec::drain.
2018-09-17Adjust the docs of `from_raw_parts` to match the implementationTobias Bucher-4/+4
2018-09-17Use more obvious calculation for slice size checkTobias Bucher-4/+2
2018-09-16Auto merge of #53754 - RalfJung:slice_align_to, r=alexcrichtonbors-8/+8
stabilize slice_align_to This is very hard to implement correctly, and leads to [serious bugs](https://github.com/llogiq/bytecount/pull/42) when done incorrectly. Moreover, this is needed to be able to run code that opportunistically exploits alignment on miri. So code using `align_to`/`align_to_mut` gets the benefit of a well-tested implementation *and* of being able to run in miri to test for (some kinds of) UB. This PR also clarifies the guarantee wrt. the middle part being as long as possible. Should the docs say under which circumstances the middle part could be shorter? Currently, that can only happen when running in miri.
2018-09-11Fix overflow in `from_raw_parts` size checkTobias Bucher-3/+5
2018-09-10A slice covering exactly half the address space is not OKTobias Bucher-6/+6
2018-09-04Add `debug_assert!`s to `slice::from_raw_parts`Tobias Bucher-2/+11
Copy the documentation over to `slice::from_raw_parts_mut`.
2018-09-04Document that slices cannot be larger than `isize::MAX` bytesTobias Bucher-0/+4
Fixes #53676.
2018-09-03Link to more detailed docs in `slice::from_raw_parts_mut`Tobias Bucher-4/+7
2018-08-29Fix a comment in src/libcore/slice/mod.rsTobias Bucher-6/+1
2018-08-28stabilize slice_align_toRalf Jung-8/+8
2018-08-21Rollup merge of #53329 - frewsxcv:frewsxcv-ptr-add-sub, r=RalfJungkennytm-35/+35
Replace usages of ptr::offset with ptr::{add,sub}. Rust provides these helper methods – so let's use them!
2018-08-21Rollup merge of #53496 - matthiaskrgr:codespell_08_2018, r=varkorkennytm-3/+3
Fix typos found by codespell.
2018-08-20Replace usages of ptr::offset with ptr::{add,sub}.Corey Farwell-35/+35
2018-08-19Fix typos found by codespell.Matthias Krüger-3/+3
2018-08-19Auto merge of #52972 - RalfJung:from_raw_parts_align, r=alexcrichtonbors-0/+4
debug_assert to ensure that from_raw_parts is only used properly aligned This does not help nearly as much as I would hope because everybody uses the distributed libstd which is compiled without debug assertions. For this reason, I am not sure if this is even worth it. OTOH, this would have caught the misalignment fixed by https://github.com/rust-lang/rust/issues/42789 *if* there had been any tests actually using ZSTs with alignment >1 (we have a CI runner which has debug assertions in libstd enabled), and it seems to currently [fail in the rg testsuite](https://ci.appveyor.com/project/rust-lang/rust/build/1.0.8403/job/v7dfdcgn8ay5j6sb). So maybe it is worth it, after all. I have seen the attribute `#[rustc_inherit_overflow_checks]` in some places, does that make it so that the *caller's* debug status is relevant? Is there a similar attribute for `debug_assert!`? That could even subsume `rustc_inherit_overflow_checks`: Something like `rustc_inherit_debug_flag` could affect *all* places that change the generated code depending on whether we are in debug or release mode. In fact, given that we have to keep around the MIR for generic functions anyway, is there ever a reason *not* to handle the debug flag that way? I guess currently we apply debug flags like `cfg` so this is dropped early during the MIR pipeline? EDIT: I learned from @eddyb that because of how `debug_assert!` works, this is not realistic. Well, we could still have it for the rustc CI runs and then maybe, eventually, when libstd gets compiled client-side and there is both a debug and a release build... then this will also benefit users.^^
2018-08-12Rollup merge of #53059 - ljedrz:unneeded_returns, r=kennytmGuillaume Gomez-10/+10
Remove explicit returns where unnecessary
2018-08-05Correct invalid feature attributesvarkor-5/+5
2018-08-04Remove redundant field names in structsljedrz-6/+6
2018-08-04Remove explicit returns where unnecessaryljedrz-10/+10
2018-08-02test that align_of handles alignment properly for the mid partRalf Jung-0/+2
2018-08-02debug_assert to ensure that from_raw_parts is only used properly alignedRalf Jung-0/+2
2018-08-02Auto merge of #52206 - RalfJung:zst-slices, r=alexcrichtonbors-212/+151
slices: fix ZST slice iterators making up pointers; debug_assert alignment in from_raw_parts This fixes the problem that we are fabricating pointers out of thin air. I also managed to share more code between the mutable and shared iterators, while reducing the amount of macros. I am not sure how useful it really is to add a `debug_assert!` in libcore. Everybody gets a release version of that anyway, right? Is there at least a CI job that runs the test suite with a debug version? Fixes #42789
2018-08-02use the same length computation everywhereRalf Jung-21/+10
2018-08-02Introduce another way to compute the length, to fix position codegen regressionRalf Jung-8/+21
2018-08-02simplify len macro: No longer require the typeRalf Jung-12/+19
Also use ident, not expr, to avoid accidental side-effects
2018-08-02macro-inline len() and is_empty() to fix performance regressionsRalf Jung-20/+29
This also changes the IR for nth(), but the new IR actually looks nicer that the old (and it is one instruction shorter).
2018-08-02make the code for nth closer to what it used to beRalf Jung-3/+4
2018-08-02use wrapping_offset; fix logic error in nthRalf Jung-10/+12