Skip to content

Commit e3ff397

Browse files
committed
Use Rc<str> instead of Rc<String> in HashMap docs
1 parent ee1014e commit e3ff397

File tree

1 file changed

+7
-7
lines changed
  • src/libstd/collections/hash

1 file changed

+7
-7
lines changed

src/libstd/collections/hash/map.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -2341,14 +2341,14 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
23412341
/// use std::collections::hash_map::{Entry, HashMap};
23422342
/// use std::rc::Rc;
23432343
///
2344-
/// let mut map: HashMap<Rc<String>, u32> = HashMap::new();
2345-
/// map.insert(Rc::new("Stringthing".to_string()), 15);
2344+
/// let mut map: HashMap<Rc<str>, u32> = HashMap::new();
2345+
/// map.insert("Stringthing".into(), 15);
23462346
///
2347-
/// let my_key = Rc::new("Stringthing".to_string());
2347+
/// let my_key: Rc<str> = "Stringthing".into();
23482348
///
23492349
/// if let Entry::Occupied(entry) = map.entry(my_key) {
23502350
/// // Also replace the key with a handle to our other key.
2351-
/// let (old_key, old_value): (Rc<String>, u32) = entry.replace_entry(16);
2351+
/// let (old_key, old_value): (Rc<str>, u32) = entry.replace_entry(16);
23522352
/// }
23532353
///
23542354
/// ```
@@ -2371,14 +2371,14 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
23712371
/// use std::collections::hash_map::{Entry, HashMap};
23722372
/// use std::rc::Rc;
23732373
///
2374-
/// let mut map: HashMap<Rc<String>, u32> = HashMap::new();
2375-
/// let mut known_strings: Vec<Rc<String>> = Vec::new();
2374+
/// let mut map: HashMap<Rc<str>, u32> = HashMap::new();
2375+
/// let mut known_strings: Vec<Rc<str>> = Vec::new();
23762376
///
23772377
/// // Initialise known strings, run program, etc.
23782378
///
23792379
/// reclaim_memory(&mut map, &known_strings);
23802380
///
2381-
/// fn reclaim_memory(map: &mut HashMap<Rc<String>, u32>, known_strings: &[Rc<String>] ) {
2381+
/// fn reclaim_memory(map: &mut HashMap<Rc<str>, u32>, known_strings: &[Rc<str>] ) {
23822382
/// for s in known_strings {
23832383
/// if let Entry::Occupied(entry) = map.entry(s.clone()) {
23842384
/// // Replaces the entry's key with our version of it in `known_strings`.

0 commit comments

Comments
 (0)