Commit Graph

218 Commits

Author SHA1 Message Date
Pietro Albini d894ce8827 fmt 2025-01-08 22:11:33 +01:00
Pietro Albini 4ae92b7adb update version placeholders 2025-01-08 20:02:18 +01:00
Kevin Reid 6a43716ada Specify only that duplicates are discarded, not the order. 2024-12-22 08:16:54 -08:00
Kevin Reid b5e8a5d393 Document collection From and FromIterator impls that drop duplicate keys.
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-21 19:57:42 -08:00
Ralf Jung 7ac7b4c285 ./x miri: fix sysroot build 2024-12-03 07:52:01 +01:00
Ralf Jung 3a9bc76f80 stabilize const_collections_with_hasher and build_hasher_default_const_new 2024-12-02 16:34:39 +01:00
timvisee 89b20e95fd Also use zero when referencing to capacity or length 2024-11-28 09:47:11 +01:00
Nicholas Nethercote 2765432d32 Improve {BTreeMap,HashMap}::get_key_value docs.
They are unusual methods. The docs don't really describe the cases when
they might be useful (as opposed to just `get`), and the examples don't
demonstrate the interesting cases at all.

This commit improves the docs and the examples.
2024-11-18 16:53:12 +11:00
Matthias Krüger 3ab4477ba7 Rollup merge of #120077 - SUPERCILEX:set-entry, r=Amanieu
Add Set entry API

See https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/HashSet.3A.3Aentry/near/413224639 and https://github.com/rust-lang/rust/issues/60896#issuecomment-678708111

Closes https://github.com/rust-lang/rfcs/issues/1490
2024-11-11 21:58:28 +01:00
Alex Saveau 33f500d52b Add Set entry API
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2024-11-02 15:13:23 -04:00
Ralf Jung 34432f7494 const_with_hasher test: actually construct a usable HashMap 2024-11-02 11:27:14 +01:00
Ralf Jung 854e3c43e0 library: consistently use American spelling for 'behavior' 2024-10-25 12:02:47 +02:00
Josh Stone f204e2c23b replace placeholder version
(cherry picked from commit 567fd9610c)
2024-10-15 20:13:55 -07:00
ltdk 11f738fcb2 impl Default for Hash{Map,Set} iterators that don't already have it 2024-10-02 23:43:48 -04:00
Urgau 8760a401bd Update hashbrown to 0.15 and adjust some methods
as well as removing some from std as they no longer
exists in Hashbrown it-self.
2024-10-02 09:44:51 +02:00
Ralf Jung 4529b86196 make test_lots_of_insertions test take less long in Miri 2024-10-01 11:03:05 +02:00
Nicola Krumschmidt 87f17f3ccb Fix std tests for wasm32-wasip2 target 2024-09-29 04:48:13 +02:00
Michael Goulet c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
GnomedDev 364e552940 [Clippy] Swap iter_over_hash_type to use diagnostic items instead of paths 2024-09-19 13:13:43 +01:00
GnomedDev a786be5d06 [Clippy] Swap map_entry to use diagnostic items instead of paths 2024-09-19 08:26:37 +01:00
GnomedDev a18564c198 [Clippy] Swap manual_retain to use diagnostic items instead of paths 2024-09-18 17:20:44 +01:00
Félix Saparelli 0b2235d732 Stabilize entry_insert 2024-09-13 11:45:44 +12:00
James Liu 4198594ef2 Clarify docs for std::collections
Page affected: https://doc.rust-lang.org/std/collections/index.html#performance

Changes:

- bulleted conventions
- expanded definitions on terms used
- more accessible language
- merged Sequence and Map performance cost tables
2024-09-10 14:25:38 -07:00
Nicholas Nethercote 84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Jubilee Young 87d850dff0 std: Unsafe-wrap HashMap::get_many_unchecked_mut 2024-07-14 16:49:16 -07:00
Jubilee Young 4572ed6389 std: deny(unsafe_op_in_unsafe_fn) but allow sites
This provides a list of locations to hunt down issues in.
2024-07-14 16:44:01 -07:00
Tim Kurdov 9436fbe00d Fix typo in the docs of HashMap::raw_entry_mut 2024-06-03 17:35:58 +01:00
Matthias Krüger 21deaed4a1 Rollup merge of #122201 - coolreader18:doc-clone_from, r=dtolnay
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-04-17 18:01:37 +02:00
Sky 49dd50f880 Add "put" as a confusable for insert on hash map/set 2024-03-19 14:28:01 -04:00
Noa c0e913fdd7 Document overrides of clone_from()
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-03-08 12:27:24 -06:00
Esteban Küber e5b3c7ef14 Add rustc_confusables annotations to some stdlib APIs
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
2024-02-22 18:04:55 +00:00
yukang ad526d831e add missing potential_query_instability for keys and values in hashmap 2024-01-30 12:43:10 +08:00
bors 1828461982 Auto merge of #117756 - a1phyr:hashmap_fold, r=the8472
`HashMap`/`HashSet`: forward `fold` implementations of iterators

Use [rust-lang/hasbrown#480](https://github.com/rust-lang/hashbrown/pull/480) in `std`

Note: this needs a version bump of hashbrown before merging
2024-01-20 17:53:26 +00:00
Jake Goulding 5772818dc8 Adjust library tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
Benoît du Garreau 7d369f9830 Specialize count too 2023-12-04 19:48:20 +01:00
Benoît du Garreau 6318cbbe49 HashMap/HashSet: forward fold implementations of iterators 2023-12-04 19:48:20 +01:00
ltdk 8337e86b28 Add insta-stable std::hash::{DefaultHasher, RandomState} exports 2023-11-02 20:35:20 -04:00
ltdk 075409ddd9 Move RandomState and DefaultHasher into std::hash, but don't export for now 2023-11-02 20:35:20 -04:00
Oli Scherer e96ce20b34 s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
bors fc01a7432b Auto merge of #109214 - tosti007:std_collection_hash_new_rework, r=workingjubilee
Use `HashMap::with_capacity_and_hasher` instead of using base

Cleans up the internal logic for `HashMap::with_capacity` slightly.
2023-10-07 05:26:12 +00:00
Easyoakland 98e434a01e Increase clarity about Hash - Eq consistency in HashMap and HashSet docs 2023-08-07 20:31:49 -06:00
Tshepang Mbambo df3f45dbc5 avoid ambiguous word
See https://github.com/rust-lang/rust/pull/113618#pullrequestreview-1526295432
2023-07-12 20:10:52 +02:00
Tshepang Mbambo 5710fca279 update ancient note 2023-07-12 12:23:40 +02:00
Tshepang Mbambo 5b46aa1122 make HashMap::or_insert_with example more simple 2023-06-29 09:33:15 +02:00
bors 6ee4265ca6 Auto merge of #104455 - the8472:dont-drain-on-drop, r=Amanieu
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-15 00:03:10 +00:00
Matthias Krüger d54bb505d0 Rollup merge of #107619 - stepancheg:hash-set-insert, r=Amanieu
Specify behavior of HashSet::insert

`HashSet::insert` does not replace the value with equal value.

Fixes #107581.
2023-06-14 18:10:28 +02:00
The 8472 479be6ac43 update hashbrown and replace Hash{Set,Map}::DrainFilter with ExtractIf 2023-06-14 09:28:56 +02:00
Deadbeef 76dbe29104 rm const traits in libcore 2023-04-16 06:49:27 +00:00
Matthias Krüger d5c7237400 Rollup merge of #110244 - kadiwa4:unnecessary_imports, r=JohnTitor
Remove some unneeded imports / qualified paths

Continuation of #105537.
2023-04-14 21:11:13 +02:00
Yuki Okushi 7361b17740 Rollup merge of #110047 - skaunov:patch-1, r=ChrisDenton
Add link to `collections` docs to `extend` trait

I believe it would be useful here.
2023-04-14 23:00:34 +09:00