Skip to content

Commit b7aff88

Browse files
committed
minor changes to readme
1 parent 340c6a6 commit b7aff88

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ assert_eq!(a.as_ptr(), b.as_ptr());
4141

4242
`&BorrowedInterned` can be used with hash-maps
4343

44+
Note that the pointer is being used for hashing and comparing (see `Hash` and `PartialEq` trait implementations)\
45+
as opposed to hashing and comparing the actual data - because the pointers are unique for the same data as long as it "lives" in memory
46+
4447
```rust
4548

46-
let map = HashMap::<Interned, u64>::from_iter([(b"key".as_ref().into(), 1)]);
49+
let map = HashMap::<Interned, u64>::from_iter([(Interned::new(b"key"), 1)]);
4750

4851
let key = Interned::new(b"key");
4952
assert_eq!(map.get(&key), Some(&1));
@@ -56,7 +59,7 @@ assert_eq!(map.get(borrowed_key), Some(&1));
5659

5760
```rust
5861

59-
let map = BTreeMap::<Interned, u64>::from_iter([(b"key".as_ref().into(), 1)]);
62+
let map = BTreeMap::<Interned, u64>::from_iter([(Interned::new(b"key"), 1)]);
6063

6164
let key = Interned::new(b"key");
6265
assert_eq!(map.get(&key), Some(&1));

0 commit comments

Comments
 (0)