From a463cd07623a2ecfed24868eff346ed61cd65ed6 Mon Sep 17 00:00:00 2001 From: JustForFun88 <100504524+JustForFun88@users.noreply.github.com> Date: Mon, 9 May 2022 12:28:50 +0500 Subject: [PATCH] Correcting miri failure --- src/map.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/map.rs b/src/map.rs index 2a35c2b..4e44f41 100644 --- a/src/map.rs +++ b/src/map.rs @@ -995,7 +995,6 @@ where /// /// ``` /// use hashbrown::HashMap; - /// use hashbrown::TryReserveError; /// /// let mut map: HashMap<&str, isize> = HashMap::new(); /// // Map is empty and doesn't allocate memory @@ -1005,7 +1004,13 @@ where /// /// // And now map can hold at least 10 elements /// assert!(map.capacity() >= 10); - /// + /// ``` + /// If the capacity overflows, or the allocator reports a failure, then an error + /// is returned: + /// ``` + /// # fn test() { + /// use hashbrown::HashMap; + /// use hashbrown::TryReserveError; /// let mut map: HashMap = HashMap::new(); /// /// match map.try_reserve(usize::MAX) { @@ -1016,13 +1021,18 @@ where /// _ => panic!(), /// } /// - /// match map.try_reserve(usize::MAX / 32) { + /// match map.try_reserve(usize::MAX / 64) { /// Err(error) => match error { /// TryReserveError::AllocError { .. } => {} /// _ => panic!("TryReserveError::CapacityOverflow ?"), /// }, /// _ => panic!(), /// } + /// # } + /// # fn main() { + /// # #[cfg(not(miri))] + /// # test() + /// # } /// ``` #[cfg_attr(feature = "inline-more", inline)] pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {