@@ -267,6 +267,7 @@ impl<K, V> HashMap<K, V, DefaultHashBuilder> {
267267 /// assert_eq!(map.len(), 0);
268268 /// assert_eq!(map.capacity(), 0);
269269 /// ```
270+ #[ must_use]
270271 #[ cfg_attr( feature = "inline-more" , inline) ]
271272 pub fn new ( ) -> Self {
272273 Self :: default ( )
@@ -296,6 +297,7 @@ impl<K, V> HashMap<K, V, DefaultHashBuilder> {
296297 /// assert_eq!(map.len(), 0);
297298 /// assert!(map.capacity() >= 10);
298299 /// ```
300+ #[ must_use]
299301 #[ cfg_attr( feature = "inline-more" , inline) ]
300302 pub fn with_capacity ( capacity : usize ) -> Self {
301303 Self :: with_capacity_and_hasher ( capacity, DefaultHashBuilder :: default ( ) )
@@ -342,6 +344,7 @@ impl<K, V, A: Allocator> HashMap<K, V, DefaultHashBuilder, A> {
342344 /// // And it also allocates some capacity
343345 /// assert!(map.capacity() > 1);
344346 /// ```
347+ #[ must_use]
345348 #[ cfg_attr( feature = "inline-more" , inline) ]
346349 pub fn new_in ( alloc : A ) -> Self {
347350 Self :: with_hasher_in ( DefaultHashBuilder :: default ( ) , alloc)
@@ -390,6 +393,7 @@ impl<K, V, A: Allocator> HashMap<K, V, DefaultHashBuilder, A> {
390393 /// // But its capacity isn't changed
391394 /// assert_eq!(map.capacity(), empty_map_capacity)
392395 /// ```
396+ #[ must_use]
393397 #[ cfg_attr( feature = "inline-more" , inline) ]
394398 pub fn with_capacity_in ( capacity : usize , alloc : A ) -> Self {
395399 Self :: with_capacity_and_hasher_in ( capacity, DefaultHashBuilder :: default ( ) , alloc)
@@ -429,6 +433,7 @@ impl<K, V, S> HashMap<K, V, S> {
429433 ///
430434 /// map.insert(1, 2);
431435 /// ```
436+ #[ must_use]
432437 #[ cfg_attr( feature = "inline-more" , inline) ]
433438 #[ cfg_attr( feature = "rustc-dep-of-std" , rustc_const_stable_indirect) ]
434439 pub const fn with_hasher ( hash_builder : S ) -> Self {
@@ -470,6 +475,7 @@ impl<K, V, S> HashMap<K, V, S> {
470475 ///
471476 /// map.insert(1, 2);
472477 /// ```
478+ #[ must_use]
473479 #[ cfg_attr( feature = "inline-more" , inline) ]
474480 pub fn with_capacity_and_hasher ( capacity : usize , hash_builder : S ) -> Self {
475481 Self {
@@ -512,6 +518,7 @@ impl<K, V, S, A: Allocator> HashMap<K, V, S, A> {
512518 /// let mut map = HashMap::with_hasher(s);
513519 /// map.insert(1, 2);
514520 /// ```
521+ #[ must_use]
515522 #[ cfg_attr( feature = "inline-more" , inline) ]
516523 #[ cfg_attr( feature = "rustc-dep-of-std" , rustc_const_stable_indirect) ]
517524 pub const fn with_hasher_in ( hash_builder : S , alloc : A ) -> Self {
@@ -547,6 +554,7 @@ impl<K, V, S, A: Allocator> HashMap<K, V, S, A> {
547554 /// let mut map = HashMap::with_capacity_and_hasher(10, s);
548555 /// map.insert(1, 2);
549556 /// ```
557+ #[ must_use]
550558 #[ cfg_attr( feature = "inline-more" , inline) ]
551559 pub fn with_capacity_and_hasher_in ( capacity : usize , hash_builder : S , alloc : A ) -> Self {
552560 Self {
0 commit comments