From bdaf4aef0209d554a60c1449d13450f1b5064bad Mon Sep 17 00:00:00 2001 From: Kris van Rens Date: Fri, 20 Sep 2024 23:23:07 +0200 Subject: [PATCH] ADD: Explanatory note. --- src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 18dbbf8..ab435da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -260,6 +260,12 @@ where /// assert_eq!(v, &"The Answer"); /// assert_eq!(c.get(&42), Some(&"The Answer")); /// ``` + /// + /// # Notes + /// + /// Because this crate is `no_std`, we have no access to `std::borrow::ToOwned`, which means we cannot create a + /// version of `get_or_insert_with` that can create an owned value from a borrowed key. + /// #[cfg_attr(feature = "inline-more", inline)] pub fn get_or_insert_with(&mut self, k: &K, f: F) -> &V where @@ -298,6 +304,12 @@ where /// assert_eq!(v, Err("Dunno")); /// assert_eq!(c.get(&17), None); /// ``` + /// + /// # Notes + /// + /// Because this crate is `no_std`, we have no access to `std::borrow::ToOwned`, which means we cannot create a + /// version of `get_or_try_insert_with` that can create an owned value from a borrowed key. + /// #[cfg_attr(feature = "inline-more", inline)] pub fn get_or_try_insert_with(&mut self, k: &K, f: F) -> Result<&V, E> where