about summary refs log tree commit diff
path: root/library/std/src/collections/hash/set.rs
AgeCommit message (Collapse)AuthorLines
2025-05-17Docs(lib/extract_if): Unify paragraph about closure actionsPaul Mabileau-3/+3
Also fixes `HashSet`'s that incorrectly designated itself as a `list`. Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-17Docs(lib/coll/hm): Reword `extract_if` to use `element` instead of `value`Paul Mabileau-3/+3
A minor change, but it seemed interesting to unify this one's description, especially considering all the other equivalents use `element` as well. Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-05-12update version placeholdersPietro Albini-5/+5
2025-05-05Consistent trait bounds for ExtractIf Debug implsDavid Tolnay-11/+8
2025-04-09replace version placeholderBoxy-5/+5
2025-02-24Rollup merge of #134655 - GrigorenkoPV:hash_extract_if, r=cuviperTrevor Gross-8/+5
Stabilize `hash_extract_if` FCP complete: https://github.com/rust-lang/rust/issues/59618#issuecomment-2674880530 Tracking issue: #59618 Closes #59618
2025-02-07Clean up 'HashMap' and 'HashSet' docs;Gabriel Bjørnager Jensen-2/+2
2025-01-08fmtPietro Albini-4/+1
2025-01-08update version placeholdersPietro Albini-1/+1
2024-12-22Specify only that duplicates are discarded, not the order.Kevin Reid-1/+2
2024-12-22Stabilize `hash_extract_if`Pavel Grigorenko-8/+5
2024-12-21Document collection `From` and `FromIterator` impls that drop duplicate keys.Kevin Reid-0/+4
This behavior is worth documenting because there are other plausible alternatives, such as panicking when a duplicate is encountered, and it reminds the programmer to consider whether they should, for example, coalesce duplicate keys first.
2024-12-03./x miri: fix sysroot buildRalf Jung-2/+2
2024-12-02stabilize const_collections_with_hasher and build_hasher_default_const_newRalf Jung-1/+23
2024-11-28Also use zero when referencing to capacity or lengthtimvisee-2/+2
2024-11-02Add Set entry APIAlex Saveau-0/+449
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2024-10-15replace placeholder versionJosh Stone-2/+2
(cherry picked from commit 567fd9610cbfd220844443487059335d7e1ff021)
2024-10-02impl Default for Hash{Map,Set} iterators that don't already have itltdk-0/+16
2024-10-02Update hashbrown to 0.15 and adjust some methodsUrgau-32/+0
as well as removing some from std as they no longer exists in Hashbrown it-self.
2024-09-19[Clippy] Swap `iter_over_hash_type` to use diagnostic items instead of pathsGnomedDev-0/+2
2024-09-18[Clippy] Swap `manual_retain` to use diagnostic items instead of pathsGnomedDev-0/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-2/+1
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-04-17Rollup merge of #122201 - coolreader18:doc-clone_from, r=dtolnayMatthias Krüger-0/+4
Document overrides of `clone_from()` in core/std As mentioned in https://github.com/rust-lang/rust/pull/96979#discussion_r1379502413 Specifically, when an override doesn't just forward to an inner type, document the behavior and that it's preferred over simply assigning a clone of source. Also, change instances where the second parameter is "other" to "source". I reused some of the wording over and over for similar impls, but I'm not sure that the wording is actually *good*. Would appreciate feedback about that. Also, now some of these seem to provide pretty specific guarantees about behavior (e.g. will reuse the exact same allocation iff the len is the same), but I was basing it off of the docs for [`Box::clone_from`](https://doc.rust-lang.org/1.75.0/std/boxed/struct.Box.html#method.clone_from-1) - I'm not sure if providing those strong guarantees is actually good or not.
2024-03-19Add "put" as a confusable for insert on hash map/setSky-1/+1
2024-03-08Document overrides of `clone_from()`Noa-0/+4
Specifically, when an override doesn't just forward to an inner type, document the behavior and that it's preferred over simply assigning a clone of source. Also, change instances where the second parameter is "other" to "source".
2024-02-22Add `rustc_confusables` annotations to some stdlib APIsEsteban Küber-0/+3
Help with common API confusion, like asking for `push` when the data structure really has `append`. ``` error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope --> $DIR/rustc_confusables_std_cases.rs:17:7 | LL | x.size(); | ^^^^ | help: you might have meant to use `len` | LL | x.len(); | ~~~ help: there is a method with a similar name | LL | x.resize(); | ~~~~~~ ``` #59450
2023-12-04Specialize `count` tooBenoît du Garreau-0/+12
2023-12-04`HashMap`/`HashSet`: forward `fold` implementations of iteratorsBenoît du Garreau-0/+58
2023-11-02Add insta-stable std::hash::{DefaultHasher, RandomState} exportsltdk-3/+3
2023-11-02Move RandomState and DefaultHasher into std::hash, but don't export for nowltdk-2/+2
2023-10-07Auto merge of #109214 - tosti007:std_collection_hash_new_rework, ↵bors-1/+1
r=workingjubilee Use `HashMap::with_capacity_and_hasher` instead of using base Cleans up the internal logic for `HashMap::with_capacity` slightly.
2023-08-07Increase clarity about Hash - Eq consistency in HashMap and HashSet docsEasyoakland-3/+4
2023-07-12avoid ambiguous wordTshepang Mbambo-1/+1
See https://github.com/rust-lang/rust/pull/113618#pullrequestreview-1526295432
2023-07-12update ancient noteTshepang Mbambo-2/+2
2023-06-15Auto merge of #104455 - the8472:dont-drain-on-drop, r=Amanieubors-25/+24
Don't drain-on-drop in DrainFilter impls of various collections. This removes drain-on-drop behavior from various unstable DrainFilter impls (not yet for HashSet/Map) because that behavior [is problematic](https://github.com/rust-lang/rust/issues/43244#issuecomment-641638196) (because it can lead to panic-in-drop when user closures panic) and may become forbidden if [this draft RFC passes](https://github.com/rust-lang/rfcs/pull/3288). closes #101122 [ACP](https://github.com/rust-lang/libs-team/issues/136) affected tracking issues * #43244 * #70530 * #59618 Related hashbrown update: https://github.com/rust-lang/hashbrown/pull/374
2023-06-14Rollup merge of #107619 - stepancheg:hash-set-insert, r=AmanieuMatthias Krüger-1/+3
Specify behavior of HashSet::insert `HashSet::insert` does not replace the value with equal value. Fixes #107581.
2023-06-14update hashbrown and replace Hash{Set,Map}::DrainFilter with ExtractIfThe 8472-25/+24
2023-04-12remove some unneeded importsKaDiWa-1/+0
2023-03-29Use with_capacity_and_hasher instead of using basetosti007-1/+1
2023-03-20Remove outdated commentsMaybe Waffle-7/+0
2023-02-03Specify behavior of HashSet::insertStiopa Koltsov-1/+3
`HashSet::insert` does not replace the value with equal value. Fixes #107581.
2023-01-07docs: make `HashSet::retain` doctest more clearEzra Shaw-1/+1
2022-10-29fix typo in hashmap and hashset try_reserve methodjoseLuís-1/+1
2022-10-02Make Hash{Set,Map}::with_hasher unstably constNixon Enraght-Moony-1/+2
2022-09-02Fix `std::collections::HashSet::drain` documentationWojciech Kordalski-1/+1
2022-06-19Fix documentation for with_capacity and reserve families of methodsjmaargh-9/+16
Documentation for the following methods with_capacity with_capacity_in with_capacity_and_hasher reserve reserve_exact try_reserve try_reserve_exact was inconsistent and often not entirely correct where they existed on the following types Vec VecDeque String OsString PathBuf BinaryHeap HashSet HashMap BufWriter LineWriter since the allocator is allowed to allocate more than the requested capacity in all such cases, and will frequently "allocate" much more in the case of zero-sized types (I also checked BufReader, but there the docs appear to be accurate as it appears to actually allocate the exact capacity). Some effort was made to make the documentation more consistent between types as well. Fix with_capacity* methods for Vec Fix *reserve* methods for Vec Fix docs for *reserve* methods of VecDeque Fix docs for String::with_capacity Fix docs for *reserve* methods of String Fix docs for OsString::with_capacity Fix docs for *reserve* methods on OsString Fix docs for with_capacity* methods on HashSet Fix docs for *reserve methods of HashSet Fix docs for with_capacity* methods of HashMap Fix docs for *reserve methods on HashMap Fix expect messages about OOM in doctests Fix docs for BinaryHeap::with_capacity Fix docs for *reserve* methods of BinaryHeap Fix typos Fix docs for with_capacity on BufWriter and LineWriter Fix consistent use of `hasher` between `HashMap` and `HashSet` Fix warning in doc test Add test for capacity of vec with ZST Fix doc test error
2022-06-06Apply suggestions from code reviewnzrq-2/+3
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2022-06-04Update library/std/src/collections/hash/set.rsnzrq-1/+1
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2022-06-03Update set.rsnzrq-6/+4
2022-06-03Add note to documentation of HashSet::intersectionnzrq-0/+7