Inner and Outer attributes

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

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

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.