Inner and Outer attributes

#1

Hi! I wanted to find the difference between # and #!. The link tells that the first one is for outer attribute and the other is for inner attribute. So, what exactly are these outer and inner attributes?
Thanks

#2

The difference between these two type of attributes is not the behavior, but the item it is applied to.

The outer attribute is placed outside something - i.e. before the struct, or function, or module. This is usually what you want.
The inner attribute is placed inside something. This is the only way to place attributes on the crate (by writing them in the root of it), and AFAIK this use-case is the only one where you’ll really want them.

4 Likes