diff options
Diffstat (limited to 'crates/libsyntax2/src/ast/generated.rs')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index 80670ce71..1ec05c950 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs | |||
@@ -249,6 +249,25 @@ impl<R: TreeRoot> AstNode<R> for NameRef<R> { | |||
249 | 249 | ||
250 | impl<R: TreeRoot> NameRef<R> {} | 250 | impl<R: TreeRoot> NameRef<R> {} |
251 | 251 | ||
252 | // NamedField | ||
253 | #[derive(Debug, Clone, Copy)] | ||
254 | pub struct NamedField<R: TreeRoot = Arc<SyntaxRoot>> { | ||
255 | syntax: SyntaxNode<R>, | ||
256 | } | ||
257 | |||
258 | impl<R: TreeRoot> AstNode<R> for NamedField<R> { | ||
259 | fn cast(syntax: SyntaxNode<R>) -> Option<Self> { | ||
260 | match syntax.kind() { | ||
261 | NAMED_FIELD => Some(NamedField { syntax }), | ||
262 | _ => None, | ||
263 | } | ||
264 | } | ||
265 | fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } | ||
266 | } | ||
267 | |||
268 | impl<R: TreeRoot> ast::NameOwner<R> for NamedField<R> {} | ||
269 | impl<R: TreeRoot> NamedField<R> {} | ||
270 | |||
252 | // NeverType | 271 | // NeverType |
253 | #[derive(Debug, Clone, Copy)] | 272 | #[derive(Debug, Clone, Copy)] |
254 | pub struct NeverType<R: TreeRoot = Arc<SyntaxRoot>> { | 273 | pub struct NeverType<R: TreeRoot = Arc<SyntaxRoot>> { |
@@ -436,7 +455,13 @@ impl<R: TreeRoot> AstNode<R> for StructDef<R> { | |||
436 | } | 455 | } |
437 | 456 | ||
438 | impl<R: TreeRoot> ast::NameOwner<R> for StructDef<R> {} | 457 | impl<R: TreeRoot> ast::NameOwner<R> for StructDef<R> {} |
439 | impl<R: TreeRoot> StructDef<R> {} | 458 | impl<R: TreeRoot> StructDef<R> { |
459 | pub fn fields<'a>(&'a self) -> impl Iterator<Item = NamedField<R>> + 'a { | ||
460 | self.syntax() | ||
461 | .children() | ||
462 | .filter_map(NamedField::cast) | ||
463 | } | ||
464 | } | ||
440 | 465 | ||
441 | // TraitDef | 466 | // TraitDef |
442 | #[derive(Debug, Clone, Copy)] | 467 | #[derive(Debug, Clone, Copy)] |