We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a7cf7b7 + 7024a9d commit 4904bc3Copy full SHA for 4904bc3
src/libstd/borrow.rs
@@ -22,7 +22,7 @@ pub fn to_uint<T>(thing: &T) -> uint {
22
/// Determine if two borrowed pointers point to the same thing.
23
#[inline]
24
pub fn ref_eq<'a, 'b, T>(thing: &'a T, other: &'b T) -> bool {
25
- to_uint(thing) == to_uint(other)
+ (thing as *T) == (other as *T)
26
}
27
28
// Equality for region pointers
@@ -70,3 +70,17 @@ impl<'self, T: TotalEq> TotalEq for &'self T {
70
71
fn equals(&self, other: & &'self T) -> bool { (**self).equals(*other) }
72
73
+
74
+#[cfg(test)]
75
+mod tests {
76
+ use super::ref_eq;
77
78
+ #[test]
79
+ fn test_ref_eq() {
80
+ let x = 1;
81
+ let y = 1;
82
83
+ assert!(ref_eq(&x, &x));
84
+ assert!(!ref_eq(&x, &y));
85
+ }
86
+}
0 commit comments