Add documentation for name_value_literal_span methods
This commit is contained in:
parent
63816da5ed
commit
a2d1254e22
1 changed files with 14 additions and 0 deletions
|
@ -180,6 +180,13 @@ impl Attribute {
|
||||||
self.value_str().is_some()
|
self.value_str().is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This is used in case you want the value span instead of the whole attribute. Example:
|
||||||
|
///
|
||||||
|
/// ```text
|
||||||
|
/// #[doc(alias = "foo")]
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// In here, it'll return a span for `"foo"`.
|
||||||
pub fn name_value_literal_span(&self) -> Option<Span> {
|
pub fn name_value_literal_span(&self) -> Option<Span> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
AttrKind::Normal(ref item, _) => {
|
AttrKind::Normal(ref item, _) => {
|
||||||
|
@ -241,6 +248,13 @@ impl MetaItem {
|
||||||
self.value_str().is_some()
|
self.value_str().is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This is used in case you want the value span instead of the whole attribute. Example:
|
||||||
|
///
|
||||||
|
/// ```text
|
||||||
|
/// #[doc(alias = "foo")]
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// In here, it'll return a span for `"foo"`.
|
||||||
pub fn name_value_literal_span(&self) -> Option<Span> {
|
pub fn name_value_literal_span(&self) -> Option<Span> {
|
||||||
Some(self.name_value_literal()?.span)
|
Some(self.name_value_literal()?.span)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue