@@ -995,7 +995,6 @@ where
995995 ///
996996 /// ```
997997 /// use hashbrown::HashMap;
998- /// use hashbrown::TryReserveError;
999998 ///
1000999 /// let mut map: HashMap<&str, isize> = HashMap::new();
10011000 /// // Map is empty and doesn't allocate memory
@@ -1005,7 +1004,13 @@ where
10051004 ///
10061005 /// // And now map can hold at least 10 elements
10071006 /// assert!(map.capacity() >= 10);
1008- ///
1007+ /// ```
1008+ /// If the capacity overflows, or the allocator reports a failure, then an error
1009+ /// is returned:
1010+ /// ```
1011+ /// # fn test() {
1012+ /// use hashbrown::HashMap;
1013+ /// use hashbrown::TryReserveError;
10091014 /// let mut map: HashMap<i32, i32> = HashMap::new();
10101015 ///
10111016 /// match map.try_reserve(usize::MAX) {
@@ -1016,13 +1021,18 @@ where
10161021 /// _ => panic!(),
10171022 /// }
10181023 ///
1019- /// match map.try_reserve(usize::MAX / 32 ) {
1024+ /// match map.try_reserve(usize::MAX / 64 ) {
10201025 /// Err(error) => match error {
10211026 /// TryReserveError::AllocError { .. } => {}
10221027 /// _ => panic!("TryReserveError::CapacityOverflow ?"),
10231028 /// },
10241029 /// _ => panic!(),
10251030 /// }
1031+ /// # }
1032+ /// # fn main() {
1033+ /// # #[cfg(not(miri))]
1034+ /// # test()
1035+ /// # }
10261036 /// ```
10271037 #[ cfg_attr( feature = "inline-more" , inline) ]
10281038 pub fn try_reserve ( & mut self , additional : usize ) -> Result < ( ) , TryReserveError > {
0 commit comments