From 2ed959e0e3cd8f766be1055043eb221844b33ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=BCller?= Date: Thu, 20 Oct 2022 15:13:11 +0200 Subject: [PATCH] Add getters for `Module` (#697) * Add getters for `Module` * Return `Iterator` instead --- codegen/src/types/mod.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/codegen/src/types/mod.rs b/codegen/src/types/mod.rs index f2950ab5d9..bd3896bb92 100644 --- a/codegen/src/types/mod.rs +++ b/codegen/src/types/mod.rs @@ -365,6 +365,23 @@ impl Module { pub fn ident(&self) -> &Ident { &self.name } + + /// Returns this `Module`s child `mod`s. + pub fn children(&self) -> impl Iterator { + self.children.iter() + } + + /// Returns the generated types. + pub fn types( + &self, + ) -> impl Iterator, &TypeDefGen)> { + self.types.iter() + } + + /// Returns the root `mod` used for resolving type paths. + pub fn root_mod(&self) -> &Ident { + &self.root_mod + } } #[derive(Debug, Clone)]