Skip to content

Instantly share code, notes, and snippets.

@japaric
Last active August 29, 2015 14:08
Show Gist options
  • Save japaric/7e11d7dc1932b25932b5 to your computer and use it in GitHub Desktop.
Save japaric/7e11d7dc1932b25932b5 to your computer and use it in GitHub Desktop.
On top of Operator dispatch PR
fn main() {
let s: &[u8] = &[0u8, 1];
s == s; // OK
s == [0, 1]; // OK
[0, 1] == s;
//^~ error: mismatched types: expected `[_]`, found `&[u8]` (expected slice, found &-ptr)
[0u8, 1] == [0u8, 1];
//^~ error: error: mismatched types: expected `[u8]`, found `[u8, ..2]` (expected slice, found array of 2 elements)
}
fn main() {
let s: &[u8] = &[0u8, 1];
s == s; // OK
s == [0, 1]; // OK
[0, 1] == s;
//^~ error: mismatched types: expected `[_, ..2]`, found `&[u8]` (expected array of 2 elements, found &-ptr)
[0u8, 1] == [0, 1]; // OK (This works because of your `impl PartialEq for [T, ..2]`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment