Is there a shallow compare for slices that returns true if the pointers and lengths match, false otherwise? It would be useful to short-circuit sometimes.
That comparison looks fine, but I would prefer as_ptr() instead of as casting. One false case that you may or may not want would be empty slices with different pointers. I suppose it depends on how you're using this "identity" comparison.
use std::ptr;
let a = [1, 2, 3, 4];
let b = [1, 2, 3];
// True if the slices have the same address and length:
assert!(ptr::eq(&a[..3], &a[..3]));
// False if the slices have different lengths...
assert!(!ptr::eq(&a[..3], &a[..2]));
// ...or different addresses:
assert!(!ptr::eq(&a[..3], &b[..3]));