Created NestedMetaItem::name_value_literal_span method
This commit is contained in:
parent
0fa9d31c41
commit
7df0052df8
4 changed files with 22 additions and 9 deletions
|
@ -115,6 +115,10 @@ impl NestedMetaItem {
|
|||
pub fn is_meta_item_list(&self) -> bool {
|
||||
self.meta_item_list().is_some()
|
||||
}
|
||||
|
||||
pub fn name_value_literal_span(&self) -> Option<Span> {
|
||||
self.meta_item()?.name_value_literal_span()
|
||||
}
|
||||
}
|
||||
|
||||
impl Attribute {
|
||||
|
@ -175,6 +179,13 @@ impl Attribute {
|
|||
pub fn is_value_str(&self) -> bool {
|
||||
self.value_str().is_some()
|
||||
}
|
||||
|
||||
pub fn name_value_literal_span(&self) -> Option<Span> {
|
||||
match self.kind {
|
||||
AttrKind::Normal(ref item, _) => item.meta(self.span).and_then(|meta| meta.name_value_literal_span()),
|
||||
AttrKind::DocComment(..) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MetaItem {
|
||||
|
@ -227,6 +238,10 @@ impl MetaItem {
|
|||
pub fn is_value_str(&self) -> bool {
|
||||
self.value_str().is_some()
|
||||
}
|
||||
|
||||
pub fn name_value_literal_span(&self) -> Option<Span> {
|
||||
Some(self.name_value_literal()?.span)
|
||||
}
|
||||
}
|
||||
|
||||
impl AttrItem {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue