Accept idents as KW args (#6644)
Support kw arg/local variable shorthand Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -186,7 +186,7 @@ impl<T> Node<T> {
|
||||
self.comment_start = start;
|
||||
}
|
||||
|
||||
pub fn map_ref<'a, U: 'a>(&'a self, f: fn(&'a T) -> U) -> Node<U> {
|
||||
pub fn map_ref<'a, U: 'a>(&'a self, f: impl Fn(&'a T) -> U) -> Node<U> {
|
||||
Node {
|
||||
inner: f(&self.inner),
|
||||
start: self.start,
|
||||
@ -1187,7 +1187,7 @@ impl Expr {
|
||||
|
||||
pub fn ident_name(&self) -> Option<&str> {
|
||||
match self {
|
||||
Expr::Name(ident) => Some(&ident.name.name),
|
||||
Expr::Name(name) => name.local_ident().map(|n| n.inner),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -2371,7 +2371,7 @@ impl Name {
|
||||
|
||||
pub fn local_ident(&self) -> Option<Node<&str>> {
|
||||
if self.path.is_empty() && !self.abs_path {
|
||||
Some(self.name.map_ref(|n| &n.name))
|
||||
Some(self.name.map_ref(|n| &*n.name))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
Reference in New Issue
Block a user