1
Fork 0

Rename NestedMetaItem::name_value_literal.

It's a highly misleading name, because it's completely different to
`MetaItem::name_value_literal`. Specifically, it doesn't match
`MetaItemKind::NameValue` (e.g. `#[foo = 3]`), it matches
`MetaItemKind::List` (e.g. `#[foo(3)]`).
This commit is contained in:
Nicholas Nethercote 2024-04-24 14:25:59 +10:00
parent d5ec9b458a
commit 8d4655d9ec
3 changed files with 5 additions and 4 deletions

View file

@ -464,8 +464,9 @@ impl NestedMetaItem {
self.meta_item().and_then(|meta_item| meta_item.meta_item_list())
}
/// Returns a name and single literal value tuple of the `MetaItem`.
pub fn name_value_literal(&self) -> Option<(Symbol, &MetaItemLit)> {
/// If it's a singleton list of the form `foo(lit)`, returns the `foo` and
/// the `lit`.
pub fn singleton_lit_list(&self) -> Option<(Symbol, &MetaItemLit)> {
self.meta_item().and_then(|meta_item| {
meta_item.meta_item_list().and_then(|meta_item_list| {
if meta_item_list.len() == 1