The chapter on unsized types in the first edition book says that:
Only the last field in a struct may have a dynamically sized type; the other fields must not. Enum variants must not have dynamically sized types as data.
Here I'm not able to understand reason behind such restriction. What make difference in last field?
In Rust since the memory layout is unspecified the restriction of the dynamically sized type (DST) field being last is not technically necessary. That being said, the compiler has to know the size of all but one field and in memory the dynamically sized field has to be last, otherwise it couldn't statically calculate the offsets of all fields.
So requiring the DST to be last in the code is consistent with the required memory layout.