This commit is contained in:
Aleksey Kladov
2021-01-20 01:56:11 +03:00
parent 63f509f492
commit 46b4f89c92
28 changed files with 69 additions and 67 deletions

View File

@@ -13,19 +13,19 @@ use crate::{
};
impl ast::Lifetime {
pub fn text(&self) -> &SmolStr {
pub fn text(&self) -> &str {
text_of_first_token(self.syntax())
}
}
impl ast::Name {
pub fn text(&self) -> &SmolStr {
pub fn text(&self) -> &str {
text_of_first_token(self.syntax())
}
}
impl ast::NameRef {
pub fn text(&self) -> &SmolStr {
pub fn text(&self) -> &str {
text_of_first_token(self.syntax())
}
@@ -34,7 +34,7 @@ impl ast::NameRef {
}
}
fn text_of_first_token(node: &SyntaxNode) -> &SmolStr {
fn text_of_first_token(node: &SyntaxNode) -> &str {
node.green().children().next().and_then(|it| it.into_token()).unwrap().text()
}
@@ -121,7 +121,7 @@ impl ast::Attr {
pub fn simple_name(&self) -> Option<SmolStr> {
let path = self.path()?;
match (path.segment(), path.qualifier()) {
(Some(segment), None) => Some(segment.syntax().first_token()?.text().clone()),
(Some(segment), None) => Some(segment.syntax().first_token()?.text().into()),
_ => None,
}
}