For instance:
struct Foo<'a> { bar: &'a str }
fn main() {
let foo_instance = Foo { bar: "bar" };
let some_vector: Vec<&Foo> = vec![&foo_instance];
assert!(*some_vector[0] == foo_instance);
}
I want to check if it refers foo_instanceto the same instance as it *some_vector[0]does, but I cannot do this ...
I do not want to know if the two copies are equal; I want to check if the variables point to the same instance in memory
Can this be done?
source
share