I haven’t yet formed an opinion about this feature but syntactically I would suggest considering the following instead of type Baz = struct { some_field: String } to clarify that structural typing is not what is going on here.
Note that consts and functions look something like this in top level scope.
const N: usize = 0;
fn f() {}
We write associated consts and associated functions using the same syntax.
struct Struct;
impl Struct {
const N: usize = 0;
fn f() {}
}
And if you have associated consts and associated functions in a trait, still the same syntax.
trait Trait {
const N: usize;
fn f();
}
impl Trait for Struct {
const N: usize = 0;
fn f() {}
}
So to me it feels syntactically less of a jump to go to associated structs / enums.
impl Struct {
struct X {
some_field: String,
}
}
And from there to the same thing in traits.
trait Trait2 {
type X;
}
impl Trait2 for Struct {
struct X {
some_field: String,
}
}