Skip to content

Commit

Permalink
ADD: Explanatory note.
Browse files Browse the repository at this point in the history
  • Loading branch information
krisvanrens committed Sep 20, 2024
1 parent 02bcd36 commit bdaf4ae
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F>(&mut self, k: &K, f: F) -> &V
where
Expand Down Expand Up @@ -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<F, E>(&mut self, k: &K, f: F) -> Result<&V, E>
where
Expand Down

0 comments on commit bdaf4ae

Please sign in to comment.