Hello, I have the following custom type:
#[derive(Debug, Copy, Clone, Hash)]
pub struct NodeId(pub usize);
impl PartialEq for NodeId {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}
impl From<usize> for NodeId {
fn from(id: usize) -> Self {
NodeId(id)
}
}
impl Eq for NodeId {}
And I would like to use it in a vec like the following:
let id = NodeId(0);
let vec: Vec<Node> = vec![...];
let element = vec[id];
let option_element = vec.get(id);
But I get the following error slice indices are of type "usize" or ranges of "usize"
, with the following advice
help: the trait
std::slice::SliceIndex<[graph_engine::model::node::NodeRef]>
is not implemented forgraph_engine::model::ids::NodeId
I looked at the documentation and implementing SliceIndex doesn't seems trivial at all...