This crate provides sets that allow borrowing while inserting entries.
While inserting entries while referencing other entries in the same set is allowed, removing entries is not possible as it may invalidate references that are held to said data.
The following code won't work:
```rust use std::collections::HashSet;
fn main() { let mut set = HashSet::with_capacity(10); set.insert("hello"); let hello = set.get(&"hello").unwrap();
// Error: Cannot borrow `set` as mutable because it is also borrowed as immutable.
set.insert("world");
assert_eq!(hello, &"hello");
} ```
Using Stonks, we can do the following thanks to interior mutability:
```rust use stonks::StonksSet;
fn main() { // Our set doesn't need to be mutable. let set = StonksSet::withcapacity(10); // Insert some data. set.insert("hello"); // We now have a refefence to the data we previously inserted. let hello = set.get(&"hello").unwrap(); // We can insert more data despite holding a reference to it. set.insert("world"); asserteq!(hello, set.get(&"hello").unwrap()); } ```