Unsized tuple coercions by qnighy · Pull Request #42527 · rust-lang/rust (original) (raw)

Implement Eq/Hash/Debug etc. for unsized tuples.

As I mentioned in [the comment in rust-lang#18469](rust-lang#18469 (comment)), the implementations of PartialEq, Eq, PartialOrd, Ord, Debug, Hash can be generalized to unsized tuples.

This is consistent with the derive behavior for unsized structs.

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
struct MyTuple<X, Y, Z: ?Sized>(X, Y, Z);

fn f(x: &MyTuple<i32, i32, [i32]>) {
    x == x;
    x < x;
    println!("{:?}", x);
}

Questions: