Type validation: `type X = T` vs `let x: T`

⚓ rust    📅 2025-05-16    👤 surdeus    👁️ 4      

surdeus

Warning

This post was published 45 days ago. The information described in this article may have changed.

Just a tiny curious bit: how come

type Tp = (u8, [str]);

doesn't alarm the compiler, yet

let tp: &(u8, [str]);

fails immediately with

// the size for values of type `str` cannot be known at compilation time
// the trait `Sized` is not implemented for `str`
// slice and array elements must have `Sized` type

Are the type and/or use declarations auto-deferred?

1 post - 1 participant

Read full topic

🏷️ rust_feed