@@ -2416,14 +2416,14 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
2416
2416
/// use std::collections::hash_map::{Entry, HashMap};
2417
2417
/// use std::rc::Rc;
2418
2418
///
2419
- /// let mut map: HashMap<Rc<String >, u32> = HashMap::new();
2420
- /// map.insert(Rc::new( "Stringthing".to_string() ), 15);
2419
+ /// let mut map: HashMap<Rc<str >, u32> = HashMap::new();
2420
+ /// map.insert("Stringthing".into( ), 15);
2421
2421
///
2422
- /// let my_key = Rc::new( "Stringthing".to_string() );
2422
+ /// let my_key: Rc<str> = "Stringthing".into( );
2423
2423
///
2424
2424
/// if let Entry::Occupied(entry) = map.entry(my_key) {
2425
2425
/// // Also replace the key with a handle to our other key.
2426
- /// let (old_key, old_value): (Rc<String >, u32) = entry.replace_entry(16);
2426
+ /// let (old_key, old_value): (Rc<str >, u32) = entry.replace_entry(16);
2427
2427
/// }
2428
2428
///
2429
2429
/// ```
@@ -2446,14 +2446,14 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
2446
2446
/// use std::collections::hash_map::{Entry, HashMap};
2447
2447
/// use std::rc::Rc;
2448
2448
///
2449
- /// let mut map: HashMap<Rc<String >, u32> = HashMap::new();
2450
- /// let mut known_strings: Vec<Rc<String >> = Vec::new();
2449
+ /// let mut map: HashMap<Rc<str >, u32> = HashMap::new();
2450
+ /// let mut known_strings: Vec<Rc<str >> = Vec::new();
2451
2451
///
2452
2452
/// // Initialise known strings, run program, etc.
2453
2453
///
2454
2454
/// reclaim_memory(&mut map, &known_strings);
2455
2455
///
2456
- /// fn reclaim_memory(map: &mut HashMap<Rc<String >, u32>, known_strings: &[Rc<String >] ) {
2456
+ /// fn reclaim_memory(map: &mut HashMap<Rc<str >, u32>, known_strings: &[Rc<str >] ) {
2457
2457
/// for s in known_strings {
2458
2458
/// if let Entry::Occupied(entry) = map.entry(s.clone()) {
2459
2459
/// // Replaces the entry's key with our version of it in `known_strings`.
0 commit comments