1 The Unsize trait should not be implemented directly. All implementations of
2 Unsize are provided automatically by the compiler.
4 Erroneous code example:
9 use std::marker::Unsize;
13 impl<T> Unsize<T> for MyType {}
16 If you are defining your own smart pointer type and would like to enable
17 conversion from a sized to an unsized type with the
18 [DST coercion system][RFC 982], use [`CoerceUnsized`] instead.
21 #![feature(coerce_unsized)]
23 use std::ops::CoerceUnsized;
25 pub struct MyType<T: ?Sized> {
26 field_with_unsized_type: T,
29 impl<T, U> CoerceUnsized<MyType<U>> for MyType<T>
30 where T: CoerceUnsized<U> {}
33 [RFC 982]: https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md
34 [`CoerceUnsized`]: https://doc.rust-lang.org/std/ops/trait.CoerceUnsized.html