@@ -995,7 +995,6 @@ where
995
995
///
996
996
/// ```
997
997
/// use hashbrown::HashMap;
998
- /// use hashbrown::TryReserveError;
999
998
///
1000
999
/// let mut map: HashMap<&str, isize> = HashMap::new();
1001
1000
/// // Map is empty and doesn't allocate memory
@@ -1005,7 +1004,13 @@ where
1005
1004
///
1006
1005
/// // And now map can hold at least 10 elements
1007
1006
/// 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;
1009
1014
/// let mut map: HashMap<i32, i32> = HashMap::new();
1010
1015
///
1011
1016
/// match map.try_reserve(usize::MAX) {
@@ -1016,13 +1021,18 @@ where
1016
1021
/// _ => panic!(),
1017
1022
/// }
1018
1023
///
1019
- /// match map.try_reserve(usize::MAX / 32 ) {
1024
+ /// match map.try_reserve(usize::MAX / 64 ) {
1020
1025
/// Err(error) => match error {
1021
1026
/// TryReserveError::AllocError { .. } => {}
1022
1027
/// _ => panic!("TryReserveError::CapacityOverflow ?"),
1023
1028
/// },
1024
1029
/// _ => panic!(),
1025
1030
/// }
1031
+ /// # }
1032
+ /// # fn main() {
1033
+ /// # #[cfg(not(miri))]
1034
+ /// # test()
1035
+ /// # }
1026
1036
/// ```
1027
1037
#[ cfg_attr( feature = "inline-more" , inline) ]
1028
1038
pub fn try_reserve ( & mut self , additional : usize ) -> Result < ( ) , TryReserveError > {
0 commit comments