about summary refs log tree commit diff
path: root/library/alloc/src/slice.rs
AgeCommit message (Collapse)AuthorLines
2021-10-09Add #[must_use] to string/char transformation methodsJohn Kugelman-0/+4
These methods could be misconstrued as modifying their arguments instead of returning new values. Where possible I made the note recommend a method that does mutate in place.
2021-06-23Use HTTPS links where possibleSmitty-1/+1
2021-05-05alloc: Add unstable Cfg feature `no-global_oom_handling`John Ericson-2/+30
For certain sorts of systems, programming, it's deemed essential that all allocation failures be explicitly handled where they occur. For example, see Linus Torvald's opinion in [1]. Merely not calling global panic handlers, or always `try_reserving` first (for vectors), is not deemed good enough, because the mere presence of the global OOM handlers is burdens static analysis. One option for these projects to use rust would just be to skip `alloc`, rolling their own allocation abstractions. But this would, in my opinion be a real shame. `alloc` has a few `try_*` methods already, and we could easily have more. Features like custom allocator support also demonstrate and existing to support diverse use-cases with the same abstractions. A natural way to add such a feature flag would a Cargo feature, but there are currently uncertainties around how std library crate's Cargo features may or not be stable, so to avoid any risk of stabilizing by mistake we are going with a more low-level "raw cfg" token, which cannot be interacted with via Cargo alone. Note also that since there is no notion of "default cfg tokens" outside of Cargo features, we have to invert the condition from `global_oom_handling` to to `not(no_global_oom_handling)`. This breaks the monotonicity that would be important for a Cargo feature (i.e. turning on more features should never break compatibility), but it doesn't matter for raw cfg tokens which are not intended to be "constraint solved" by Cargo or anything else. To support this use-case we create a new feature, "global-oom-handling", on by default, and put the global OOM handler infra and everything else it that depends on it behind it. By default, nothing is changed, but users concerned about global handling can make sure it is disabled, and be confident that all OOM handling is local and explicit. For this first iteration, non-flat collections are outright disabled. `Vec` and `String` don't yet have `try_*` allocation methods, but are kept anyways since they can be oom-safely created "from parts", and we hope to add those `try_` methods in the future. [1]: https://lore.kernel.org/lkml/CAHk-=wh_sNLoz84AUUzuqXEsYH35u=8HV3vK-jbRbJ_B-JjGrg@mail.gmail.com/
2021-04-13Remove slice diagnostic itemCameron Steffen-1/+0
2021-03-27adjust documentation links for slice ascii case functions to use newer ↵Violet-2/+2
rustdoc link format
2021-03-27update links to make_ascii_lowercase for slice to point to methods on the ↵Violet-2/+2
same type, rather than on u8
2021-03-09convert slice doc link to intra-doc linksFrançois Mockers-5/+5
2021-02-25Convert primitives to use intra-doc linksJoshua Nelson-11/+11
2021-02-23Rollup merge of #82128 - anall:feature/add_diagnostic_items, r=davidtwcoDylan DPC-0/+1
add diagnostic items for OsString/PathBuf/Owned as well as to_vec on slice This is adding diagnostic items to be used by rust-lang/rust-clippy#6730, but my understanding is the clippy-side change does need to be done over there since I am adding a new clippy feature. Add diagnostic items to the following types: OsString (os_string_type) PathBuf (path_buf_type) Owned (to_owned_trait) As well as the to_vec method on slice/[T]
2021-02-15requested/proposed changesAndrea Nall-1/+1
2021-02-15add diagnostic itemsAndrea Nall-0/+1
Add diagnostic items to the following types: OsString (os_string_type) PathBuf (path_buf_type) Owned (to_owned_trait) As well as the to_vec method on slice/[T]
2021-02-12Rename `Range::ensure_subset_of` to `slice::range`dylni-0/+2
2020-12-31Replace the tracking issue for the slice_group_by featureClément Renault-1/+1
2020-12-10Fix the fmt issuesClément Renault-2/+2
2020-12-10Use none as the issue instead of 0Clément Renault-1/+1
2020-12-10Introduce the GroupBy and GroupByMut IteratorsClément Renault-0/+2
2020-12-04 Rename `AllocRef` to `Allocator` and `(de)alloc` to `(de)allocate`Tim Diekmann-12/+12
2020-11-22Change slice::to_vec to not use extend_from_slicekadmin-7/+59
This also required adding a loop guard in case clone panics Add specialization for copy There is a better version for copy, so I've added specialization for that function and hopefully that should speed it up even more. Switch FromIter<slice::Iter> to use `to_vec` Test different unrolling version for to_vec Revert to impl From benchmarking, it appears this version is faster
2020-11-18Add support for custom allocators in `Vec`Tim Diekmann-8/+33
2020-10-23Rollup merge of #77969 - ryan-scott-dev:bigo-notation-consistency, r=m-ou-seYuki Okushi-7/+7
Doc formating consistency between slice sort and sort_unstable, and big O notation consistency Updated documentation for slice sorting methods to be consistent between stable and unstable versions, which just ended up being minor formatting differences. I also went through and updated any doc comments with big O notation to be consistent with #74010 by italicizing them rather than having them in a code block.
2020-10-15Made slice sort documentation consistent between stable and unstable versionsRyan Scott-7/+7
2020-09-18Move `slice::check_range` to `RangeBounds`dylni-2/+0
2020-09-16Rollup merge of #75026 - JulianKnodt:array_windows, r=AmanieuTyler Mandry-0/+2
Add array_windows fn This mimicks the functionality added by array_chunks, and implements a const-generic form of `windows`. It makes egregious use of `unsafe`, but by necessity because the array must be re-interpreted as a slice of arrays, and unlike array_chunks this cannot be done by casting the original array once, since each time the index is advanced it needs to move one element, not `N`. I'm planning on adding more tests, but this should be good enough as a premise for the functionality. Notably: should there be more functions overwritten for the iterator implementation/in general? ~~I've marked the issue as #74985 as there is no corresponding exact issue for `array_windows`, but it's based of off `array_chunks`.~~ Edit: See Issue #75027 created by @lcnr for tracking issue ~~Do not merge until I add more tests, please.~~ r? @lcnr
2020-09-16Add array window fnkadmin-0/+2
Updated issue to #75027 Update to rm oob access And hopefully fix docs as well Fixed naming conflict in test Fix test which used 1-indexing Nth starts from 0, woops Fix a bunch of off by 1 errors See https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=757b311987e3fae1ca47122969acda5a Add even more off by 1 errors And also write `next` and `next_back` in terms of `nth` and `nth_back`. Run fmt Fix forgetting to change fn name in test add nth_back test & document unsafe Remove as_ref().unwrap() Documented occurrences of unsafe, noting what invariants are maintained
2020-09-15fix slice::check_range aliasing problemsRalf Jung-0/+2
2020-09-04Re-export ArrayChunksMut in allocJosh Stone-0/+2
2020-08-21Use intra-doc-links in `alloc`LeSeulArtichaut-7/+3
2020-08-01add tracking issueBastian Kauschke-1/+1
2020-07-30liballoc export ArrayChunksBastian Kauschke-0/+2
2020-07-27mv std libs to library/mark-0/+1069