1
Fork 0

Created NestedMetaItem::name_value_literal_span method

This commit is contained in:
Guillaume Gomez 2020-11-28 16:11:25 +01:00
parent 0fa9d31c41
commit 7df0052df8
4 changed files with 22 additions and 9 deletions

View file

@ -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 {