I cannot put a Rc<RefCell<..>>
as a key in a HashMap. The error (below) refers to RefCell
not Rc
. I do not understand. Since Rc
has hash
why is the compiler looking inside to the RefCell
?
use std::cell::{RefCell};
use std::collections::HashMap;
use std::rc::Rc;
fn main(){
let h:HashMap<Rc<RefCell<usize>>, bool> = HashMap::new();
}
error[E0277]: the trait bound `std::cell::RefCell<usize>: std::hash::Hash` is not satisfied
--> src/main.rs:5:47
|
5 | let h:HashMap<Rc<RefCell<usize>>, bool> = HashMap::new();
| ^^^^^^^^^^^^ the trait `std::hash::Hash` is not implemented for `std::cell::RefCell<usize>`
|