std-method
Rust Rc::ptr_eq
Compare allocation identity rather than payload equality. Equal contents may be stored in distinct allocations; this matters for graph nodes and cache identities. Expected output (not executed): true true false Why: a and c have equal numbers but distinct allocations. Common mistake: Using value equality to infer that two graph handles refer to the same node.
Formal Syntax & Structure
rust syntaxrust
Rc::ptr_eq(&a, &b) -> boolWorking Example
Example Snippetrust
use std::rc::Rc;fn main() { let a = Rc::new(17); let b = Rc::clone(&a); let c = Rc::new(17); println!("{} {} {}", a == c, Rc::ptr_eq(&a, &b), Rc::ptr_eq(&a, &c));}