Can traits be documented?

The documentation for traits does not does not include the outer attribute in the grammar.

This isn't critical but I was curious, are all items belonging to type-namespace the same (i.e can't be documented)?

I assume this can not be the case since structs are, and they can be documented?

So I am unsure whether I am misreading the grammar there.

The outer attribute syntax is part of the grammar of items as a whole, not specific item syntaxes.

And, of course, traits in practice do have documentation (example).

2 Likes

I checked associated functions/items and that confused me.

But it seems they aren't items? Not formally in the list although they kind of are items.

The Item nonterminal in the grammar essentially means "module-level item". Associated items (and the AssociatedItem nonterminal) are distinct from items in that sense. There's no need for them to be related as far as the grammar is concerned.

2 Likes