@@ -394,14 +394,18 @@ macro_rules! repetition_utils {
394394
395395/// Creates a [`HashMap`] containing the arguments.
396396///
397- /// This macro creates or either an empty [`HashMap`] using
398- /// [`HashMap::new`] if there are no arguments, or generates
399- /// a [`HashMap::insert`] call for each element.
397+ /// [`hash_map!`] allows specifying the entries that make
398+ /// up the [`HashMap`] where the key and value are separated by a `=>`.
400399///
401- /// This macro allows trailing commas.
400+ /// The entries are separated by commas, where a trailing comma can be used
401+ /// for purposes like macro generation as well as many other things...
402402///
403- /// This macro is used by concatenating comma separated sequences
404- /// of `<key:expr> => <value:expr>`.
403+ /// It is semantically equivalent to using repeated [`HashMap::insert`]
404+ /// on a newly created hashmap. On the other hand, calling [`hash_map!`]
405+ /// without any argument is equivalent to invoking [`HashMap::new`].
406+ ///
407+ /// A non empty [`hash_map!`] invocation calls [`HashMap::with_capacity`] and evaluates
408+ /// the argument size constantly passing it to the function itself.
405409///
406410/// # Examples
407411///
@@ -415,9 +419,10 @@ macro_rules! repetition_utils {
415419///
416420/// assert_eq!(map.get("key"), Some(&"value"));
417421/// assert_eq!(map.get("key1"), Some(&"value1"));
422+ /// assert!(map.get("brrrrrrooooommm").is_none());
418423/// ```
419424///
420- /// This macro also supports trailing comma.
425+ /// And with a trailing comma
421426///
422427///```rust
423428/// #![feature(hash_map_macro)]
@@ -434,6 +439,7 @@ macro_rules! repetition_utils {
434439/// [`HashMap`]: crate::collections::HashMap
435440/// [`HashMap::new`]: crate::collections::HashMap::new
436441/// [`HashMap::insert`]: crate::collections::HashMap::insert
442+ /// [`HashMap::with_capacity`]: crate::collections::HashMap::with_capacity
437443#[ macro_export]
438444#[ allow_internal_unstable( hash_map_internals) ]
439445#[ unstable( feature = "hash_map_macro" , issue = "144032" ) ]
0 commit comments