@@ -136,13 +136,35 @@ impl Attribute {
136136 }
137137 }
138138
139+ /// Returns a list of meta items if the attribute is delimited with parenthesis:
140+ ///
141+ /// ```text
142+ /// #[attr(a, b = "c")] // Returns `Some()`.
143+ /// #[attr = ""] // Returns `None`.
144+ /// #[attr] // Returns `None`.
145+ /// ```
139146 pub fn meta_item_list ( & self ) -> Option < ThinVec < MetaItemInner > > {
140147 match & self . kind {
141148 AttrKind :: Normal ( normal) => normal. item . meta_item_list ( ) ,
142149 AttrKind :: DocComment ( ..) => None ,
143150 }
144151 }
145152
153+ /// Returns the string value in:
154+ ///
155+ /// ```text
156+ /// #[attribute = "value"]
157+ /// ^^^^^^^
158+ /// ```
159+ ///
160+ /// It returns `None` in any other cases, including doc comments if they
161+ /// are not under the form `#[doc = "..."]`.
162+ ///
163+ /// It also returns `None` for:
164+ ///
165+ /// ```text
166+ /// #[attr("value")]
167+ /// ```
146168 pub fn value_str ( & self ) -> Option < Symbol > {
147169 match & self . kind {
148170 AttrKind :: Normal ( normal) => normal. item . value_str ( ) ,
@@ -232,6 +254,18 @@ impl AttrItem {
232254 }
233255 }
234256
257+ /// Returns the string value in:
258+ ///
259+ /// ```text
260+ /// #[attribute = "value"]
261+ /// ^^^^^^^
262+ /// ```
263+ ///
264+ /// It returns `None` in any other cases like:
265+ ///
266+ /// ```text
267+ /// #[attr("value")]
268+ /// ```
235269 fn value_str ( & self ) -> Option < Symbol > {
236270 match & self . args {
237271 AttrArgs :: Eq ( _, args) => args. value_str ( ) ,
@@ -315,6 +349,18 @@ impl MetaItem {
315349 Some ( self . name_value_literal ( ) ?. span )
316350 }
317351
352+ /// Returns the string value in:
353+ ///
354+ /// ```text
355+ /// #[attribute = "value"]
356+ /// ^^^^^^^
357+ /// ```
358+ ///
359+ /// It returns `None` in any other cases like:
360+ ///
361+ /// ```text
362+ /// #[attr("value")]
363+ /// ```
318364 pub fn value_str ( & self ) -> Option < Symbol > {
319365 match & self . kind {
320366 MetaItemKind :: NameValue ( v) => v. kind . str ( ) ,
0 commit comments