From a2eee288f50249aaf8c395072839a39ce823227c Mon Sep 17 00:00:00 2001 From: "Daniel Porteous (dport)" Date: Sun, 2 Jul 2023 05:26:35 +0100 Subject: [PATCH] Add all_modules function to BuiltPackage (#8862) --- aptos-move/framework/src/built_package.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/aptos-move/framework/src/built_package.rs b/aptos-move/framework/src/built_package.rs index aa1aafef19b87..2b2ee97ba7f98 100644 --- a/aptos-move/framework/src/built_package.rs +++ b/aptos-move/framework/src/built_package.rs @@ -253,6 +253,17 @@ impl BuiltPackage { }) } + /// Returns an iterator for all compiled proper (non-script) modules, including + /// modules that are dependencies of the root modules. + pub fn all_modules(&self) -> impl Iterator { + self.package + .all_modules() + .filter_map(|unit| match &unit.unit { + CompiledUnit::Module(NamedCompiledModule { module, .. }) => Some(module), + CompiledUnit::Script(_) => None, + }) + } + /// Returns the number of scripts in the package. pub fn script_count(&self) -> usize { self.package.scripts().count()