From 08de1b4fa57ca78ad13026950b3eb024b7d2abf3 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 18 Dec 2020 18:58:42 +0100 Subject: Implement `RawAttr::filter` --- crates/syntax/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/syntax') diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs index e753b11bb..4d272f367 100644 --- a/crates/syntax/src/lib.rs +++ b/crates/syntax/src/lib.rs @@ -205,6 +205,13 @@ impl ast::Type { } } +impl ast::Attr { + /// Returns `text`, parsed as an attribute, but only if it has no errors. + pub fn parse(text: &str) -> Result { + parsing::parse_text_fragment(text, parser::FragmentKind::Attr) + } +} + /// Matches a `SyntaxNode` against an `ast` type. /// /// # Example: -- cgit v1.2.3