@@ -301,8 +301,11 @@ impl<K, V, A: Allocator> HashMap<K, V, RandomState, A> {
301301 /// # Examples
302302 ///
303303 /// ```
304+ /// # #![feature(allocator_api)]
304305 /// use std::collections::HashMap;
305- /// let mut map: HashMap<&str, i32> = HashMap::new();
306+ /// use std::alloc::Global;
307+ ///
308+ /// let map: HashMap<i32, i32> = HashMap::new_in(Global);
306309 /// ```
307310 #[ inline]
308311 #[ must_use]
@@ -321,8 +324,11 @@ impl<K, V, A: Allocator> HashMap<K, V, RandomState, A> {
321324 /// # Examples
322325 ///
323326 /// ```
327+ /// # #![feature(allocator_api)]
324328 /// use std::collections::HashMap;
325- /// let mut map: HashMap<&str, i32> = HashMap::with_capacity(10);
329+ /// use std::alloc::Global;
330+ ///
331+ /// let map: HashMap<i32, i32> = HashMap::with_capacity_in(10, Global);
326332 /// ```
327333 #[ inline]
328334 #[ must_use]
@@ -410,6 +416,18 @@ impl<K, V, S, A: Allocator> HashMap<K, V, S, A> {
410416 ///
411417 /// The `hash_builder` passed should implement the [`BuildHasher`] trait for
412418 /// the `HashMap` to be useful, see its documentation for details.
419+ ///
420+ /// # Examples
421+ ///
422+ /// ```
423+ /// #![feature(allocator_api)]
424+ /// use std::alloc::Global;
425+ /// use std::collections::HashMap;
426+ /// use std::hash::RandomState;
427+ ///
428+ /// let s = RandomState::new();
429+ /// let map: HashMap<i32, i32> = HashMap::with_hasher_in(s, Global);
430+ /// ```
413431 #[ inline]
414432 #[ must_use]
415433 #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
@@ -432,6 +450,17 @@ impl<K, V, S, A: Allocator> HashMap<K, V, S, A> {
432450 /// The `hasher` passed should implement the [`BuildHasher`] trait for
433451 /// the `HashMap` to be useful, see its documentation for details.
434452 ///
453+ /// # Examples
454+ ///
455+ /// ```
456+ /// #![feature(allocator_api)]
457+ /// use std::alloc::Global;
458+ /// use std::collections::HashMap;
459+ /// use std::hash::RandomState;
460+ ///
461+ /// let s = RandomState::new();
462+ /// let map: HashMap<i32, i32> = HashMap::with_capacity_and_hasher_in(10, s, Global);
463+ /// ```
435464 #[ inline]
436465 #[ must_use]
437466 #[ unstable( feature = "allocator_api" , issue = "32838" ) ]
0 commit comments