about summary refs log tree commit diff
path: root/library/std/src/collections
AgeCommit message (Collapse)AuthorLines
2022-02-25Switch bootstrap cfgsMark Rousskov-20/+20
2022-02-19Auto merge of #94148 - matthiaskrgr:rollup-jgea68f, r=matthiaskrgrbors-1/+10
Rollup of 7 pull requests Successful merges: - #92902 (Improve the documentation of drain members) - #93658 (Stabilize `#[cfg(panic = "...")]`) - #93954 (rustdoc-json: buffer output) - #93979 (Add debug assertions to validate NUL terminator in c strings) - #93990 (pre #89862 cleanup) - #94006 (Use a `Field` in `ConstraintCategory::ClosureUpvar`) - #94086 (Fix ScalarInt to char conversion) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-19Collections: improve the documentation of drain membersStein Somers-1/+10
2022-02-17Destabilise entry_insert5225225-2/+4
2022-02-01add a rustc::query_stability lintlcnr-0/+20
2022-01-22Disable test_try_reserve on AndroidAmanieu d'Antras-0/+1
2022-01-21Update HashMap::try_reserve test to version from hashbrownAmanieu d'Antras-5/+15
2022-01-09eplace usages of vec![].into_iter with [].into_iterLucas Kent-11/+11
2022-01-01Rollup merge of #91593 - upsuper-forks:hashmap-set-methods-bound, r=dtolnayMatthias Krüger-99/+99
Remove unnecessary bounds for some Hash{Map,Set} methods This PR moves `HashMap::{into_keys,into_values,retain}` and `HashSet::retain` from `impl` blocks with `K: Eq + Hash, S: BuildHasher` into the blocks without them. It doesn't seem to me there is any reason these methods need to be bounded by that. This change brings `HashMap::{into_keys,into_values}` on par with `HashMap::{keys,values,values_mut}` which are not bounded either.
2021-12-21Rollup merge of #90345 - passcod:entry-insert, r=dtolnayMatthias Krüger-6/+6
Stabilise entry_insert This stabilises `HashMap:Entry::insert_entry` etc. Tracking issue #65225. It will need an FCP. This was implemented in #64656 two years ago. This PR includes the rename and change discussed in https://github.com/rust-lang/rust/issues/65225#issuecomment-910652430, happy to split if needed.
2021-12-20Bump insert_entry stabilization to Rust 1.59David Tolnay-2/+2
2021-12-11Remove unnecessary bounds for some Hash{Map,Set} methodsXidorn Quan-99/+99
2021-12-11Auto merge of #91761 - matthiaskrgr:rollup-bjowmvz, r=matthiaskrgrbors-38/+37
Rollup of 11 pull requests Successful merges: - #91668 (Remove the match on `ErrorKind::Other`) - #91678 (Add tests fixed by #90023) - #91679 (Move core/stream/stream/mod.rs to core/stream/stream.rs) - #91681 (fix typo in `intrinsics::raw_eq` docs) - #91686 (Fix `Vec::reserve_exact` documentation) - #91697 (Delete Utf8Lossy::from_str) - #91706 (Add unstable book entries for parts of asm that are not being stabilized) - #91709 (Replace iterator-based set construction by *Set::From<[T; N]>) - #91716 (Improve x.py logging and defaults a bit more) - #91747 (Add pierwill to .mailmap) - #91755 (Fix since attribute for const_linked_list_new feature) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-10Rollup merge of #91482 - ↵Matthias Krüger-53/+70
JosephTLyons:update-HashMap-and-BTreeMap-documentation, r=yaahc Update documentation to use `from()` to initialize `HashMap`s and `BTreeMap`s As of Rust 1.56, `HashMap` and `BTreeMap` both have associated `from()` functions. I think using these in the documentation cleans things up a bit. It allows us to remove some of the `mut`s and avoids the Initialize-Then-Modify anti-pattern.
2021-12-09Replace iterator-based set construction by *Set::From<[T; N]>Júnior Bassani-38/+37
2021-12-04Use IntoIterator for array impl everywhere.Mara Bos-2/+2
2021-12-03Make `HashMap`s mutable againJoseph T Lyons-6/+6
2021-12-02Use `HashMap::from()` instead of using `HashMap::new()` with `HashMap::insert()`Joseph T Lyons-53/+70
2021-11-10Fix collection entry API documentation.Joseph Roitman-1/+1
2021-10-31Rollup merge of #90430 - jkugelman:must-use-std-a-through-n, r=joshtriplettMatthias Krüger-0/+5
Add #[must_use] to remaining std functions (A-N) I've run out of compelling reasons to group functions together across crates so I'm just going to go module-by-module. This is half of the remaining items from the `std` crate, from A-N. I added these functions myself. Clippy predictably ignored the `mut` ones, but I don't know why the rest weren't flagged. Check them closely, please? Maybe I overlooked good reasons. ```rust std::backtrace::Backtrace const fn disabled() -> Backtrace; std::backtrace::Backtrace<'a> fn frames(&'a self) -> &'a [BacktraceFrame]; std::collections::hash_map::RawOccupiedEntryMut<'a, K, V> fn key_mut(&mut self) -> &mut K; std::collections::hash_map::RawOccupiedEntryMut<'a, K, V> fn get_mut(&mut self) -> &mut V; std::collections::hash_map::RawOccupiedEntryMut<'a, K, V> fn get_key_value(&mut self) -> (&K, &V); std::collections::hash_map::RawOccupiedEntryMut<'a, K, V> fn get_key_value_mut(&mut self) -> (&mut K, &mut V); std::env fn var_os<K: AsRef<OsStr>>(key: K) -> Option<OsString>; std::env fn split_paths<T: AsRef<OsStr> + ?Sized>(unparsed: &T) -> SplitPaths<'_>; std::io::Error fn get_mut(&mut self) -> Option<&mut (dyn error::Error + Send + Sync + 'static)>; ``` Parent issue: #89692 r? `@joshtriplett`
2021-10-31Rollup merge of #89835 - jkugelman:must-use-expensive-computations, ↵Matthias Krüger-0/+8
r=joshtriplett Add #[must_use] to expensive computations The unifying theme for this commit is weak, admittedly. I put together a list of "expensive" functions when I originally proposed this whole effort, but nobody's cared about that criterion. Still, it's a decent way to bite off a not-too-big chunk of work. Given the grab bag nature of this commit, the messages I used vary quite a bit. I'm open to wording changes. For some reason clippy flagged four `BTreeSet` methods but didn't say boo about equivalent ones on `HashSet`. I stared at them for a while but I can't figure out the difference so I added the `HashSet` ones in. ```rust // Flagged by clippy. alloc::collections::btree_set::BTreeSet<T> fn difference<'a>(&'a self, other: &'a BTreeSet<T>) -> Difference<'a, T>; alloc::collections::btree_set::BTreeSet<T> fn symmetric_difference<'a>(&'a self, other: &'a BTreeSet<T>) -> SymmetricDifference<'a, T> alloc::collections::btree_set::BTreeSet<T> fn intersection<'a>(&'a self, other: &'a BTreeSet<T>) -> Intersection<'a, T>; alloc::collections::btree_set::BTreeSet<T> fn union<'a>(&'a self, other: &'a BTreeSet<T>) -> Union<'a, T>; // Ignored by clippy, but not by me. std::collections::HashSet<T, S> fn difference<'a>(&'a self, other: &'a HashSet<T, S>) -> Difference<'a, T, S>; std::collections::HashSet<T, S> fn symmetric_difference<'a>(&'a self, other: &'a HashSet<T, S>) -> SymmetricDifference<'a, T, S> std::collections::HashSet<T, S> fn intersection<'a>(&'a self, other: &'a HashSet<T, S>) -> Intersection<'a, T, S>; std::collections::HashSet<T, S> fn union<'a>(&'a self, other: &'a HashSet<T, S>) -> Union<'a, T, S>; ``` Parent issue: #89692 r? ```@joshtriplett```
2021-10-30Add #[must_use] to remaining std functions (A-N)John Kugelman-0/+5
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-20/+0
2021-10-28Stabilise entry_insertFélix Saparelli-4/+2
Signed-off-by: Félix Saparelli <felix@passcod.name>
2021-10-28Update doctests for renamesFélix Saparelli-2/+2
2021-10-28Expose HashMap:VacantEntry:insert_entryFélix Saparelli-1/+3
2021-10-28Rename HashMap:Entry:insert to :insert_entryFélix Saparelli-1/+1
2021-10-24Rollup merge of #89558 - lcnr:query-stable-lint, r=estebankMatthias Krüger-0/+20
Add rustc lint, warning when iterating over hashmaps r? rust-lang/wg-incr-comp
2021-10-21Clarify undefined behaviour for binary heap, btree and hashsetWilfred Hughes-2/+2
Previously, it wasn't clear whether "This could include" was referring to logic errors, or undefined behaviour. Tweak wording to clarify this sentence does not relate to UB.
2021-10-15add a `rustc::query_stability` lintlcnr-0/+20
2021-10-12Add #[must_use] to expensive computationsJohn Kugelman-0/+8
The unifying theme for this commit is weak, admittedly. I put together a list of "expensive" functions when I originally proposed this whole effort, but nobody's cared about that criterion. Still, it's a decent way to bite off a not-too-big chunk of work. Given the grab bag nature of this commit, the messages I used vary quite a bit.
2021-10-11Rollup merge of #89729 - jkugelman:must-use-core-std-constructors, ↵Guillaume Gomez-0/+6
r=joshtriplett Add #[must_use] to core and std constructors Parent issue: #89692 r? ``@joshtriplett``
2021-10-10Add #[must_use] to conversions that move selfJohn Kugelman-0/+3
2021-10-10Add #[must_use] to core and std constructorsJohn Kugelman-0/+6
2021-10-04Stabilize try_reserveKornel-5/+3
2021-10-02Make diangostic item names consistentCameron Steffen-2/+2
2021-09-26Auto merge of #89144 - sexxi-goose:insig_stdlib, r=nikomatsakisbors-0/+1
2229: Mark insignificant dtor in stdlib I looked at all public [stdlib Drop implementations](https://doc.rust-lang.org/stable/std/ops/trait.Drop.html#implementors) and categorized them into Insigificant/Maybe/Significant Drop. Reasons are noted here: https://docs.google.com/spreadsheets/d/19edb9r5lo2UqMrCOVjV0fwcSdS-R7qvKNL76q7tO8VA/edit#gid=1838773501 One thing missing from this PR is tagging HashMap as insigificant destructor as that needs some discussion. r? `@Mark-Simulacrum` cc `@nikomatsakis`
2021-09-25Rollup merge of #89216 - r00ster91:bigo, r=dtolnayManish Goregaokar-9/+9
Consistent big O notation This makes the big O time complexity notation in places with markdown support more consistent. Inspired by #89210
2021-09-25Rollup merge of #89010 - est31:intra_doc_links, r=m-ou-seManish Goregaokar-2/+4
Add some intra doc links
2021-09-25Auto merge of #88343 - steffahn:fix_code_spacing, r=jyn514bors-2/+2
Fix spacing of links in inline code. Similar to #80733, but the focus is different. This PR eliminates all occurrences of pieced-together inline code blocks like [`Box`]`<`[`Option`]`<T>>` and replaces them with good-looking ones (using HTML-syntax), like <code>[Box]<[Option]\<T>></code>. As far as I can tell, I should’ve found all of these in the standard library (regex search with `` r"`\]`|`\[`" ``) \[except for in `core::convert` where I’ve noticed other things in the docs that I want to fix in a separate PR]. In particular, unlike #80733, I’ve added almost no new instance of inline code that’s broken up into multiple links (or some link and some link-free part). I also added tooltips (the stuff in quotes for the markdown link listings) in places that caught my eye, but that’s by no means systematic, just opportunistic. [Box]: https://doc.rust-lang.org/std/boxed/struct.Box.html "Box" [`Box`]: https://doc.rust-lang.org/std/boxed/struct.Box.html "Box" [Option]: https://doc.rust-lang.org/std/option/enum.Option.html "Option" [`Option`]: https://doc.rust-lang.org/std/option/enum.Option.html "Option" Context: I got annoyed by repeatedly running into new misformatted inline code while reading the standard library docs. I know that once issue #83997 (and/or related ones) are resolved, these changes become somewhat obsolete, but I fail to notice much progress on that end right now. r? `@jyn514`
2021-09-25Apply 16 commits (squashed)Frank Steffahn-2/+2
---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::fmt ---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::{rc, sync} ---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::string ---------- Fix spacing for links inside code blocks in alloc::vec ---------- Fix spacing for links inside code blocks in core::option ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in core::result ---------- Fix spacing for links inside code blocks in core::{iter::{self, iterator}, stream::stream, poll} ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in std::{fs, path} ---------- Fix spacing for links inside code blocks in std::{collections, time} ---------- Fix spacing for links inside code blocks in and make formatting of `&str`-like types consistent in std::ffi::{c_str, os_str} ---------- Fix spacing for links inside code blocks, and improve link tooltips in std::ffi ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in std::{io::{self, buffered::{bufreader, bufwriter}, cursor, util}, net::{self, addr}} ---------- Fix typo in link to `into` for `OsString` docs ---------- Remove tooltips that will probably become redundant in the future ---------- Apply suggestions from code review Replacing `…std/primitive.reference.html` paths with just `reference` Co-authored-by: Joshua Nelson <github@jyn.dev> ---------- Also replace `…std/primitive.reference.html` paths with just `reference` in `core::pin`
2021-09-24consistent big O notationr00ster91-9/+9
2021-09-22PR fixupAman Arora-0/+1
2021-09-16Add IntoIterator intra doc link to various collectionsest31-2/+4
2021-09-09Fix typo in docs for iteratorsJesse Ruderman-1/+1
2021-08-23Rollup merge of #88230 - steffahn:a_an, r=oli-obkMara Bos-3/+3
Fix typos “a”→“an” Fix typos in comments; found using a regex to find some easy instance of incorrect usage of a vs. an. While automation was used to find these, every change was checked manually. Changes in submodules get separate PRs: * https://github.com/rust-lang/stdarch/pull/1201 * https://github.com/rust-lang/cargo/pull/9821 * https://github.com/rust-lang/miri/pull/1874 * https://github.com/rust-lang/rls/pull/1746 * https://github.com/rust-analyzer/rust-analyzer/pull/9984 _folks @ rust-analyzer are fast at merging…_ * https://github.com/rust-analyzer/rust-analyzer/pull/9985 * https://github.com/rust-analyzer/rust-analyzer/pull/9987 * https://github.com/rust-analyzer/rust-analyzer/pull/9989 _For `clippy`, I don’t know if the changes should better better be moved to a PR to the original repo._ <hr> This has some overlap with #88226, but neither is a strict superset of the other. If you want multiple commits, I can split it up; in that case, make sure to suggest a criterion for splitting.
2021-08-23Auto merge of #87598 - ccqpein:master, r=yaahcbors-2/+10
Add doctests for HashMap's into_values and into_keys methods Fixes #87591
2021-08-22Fix typos “a”→“an”Frank Steffahn-3/+3
2021-08-22Add doctests for 's into_values and into_keys methodsccQpein-2/+10
2021-08-12Auto merge of #87843 - kornelski:try_reserve, r=m-ou-sebors-9/+12
TryReserveErrorKind tests and inline A small follow-up to #87408