Skip to content

Commit

Permalink
Add all_modules function to BuiltPackage (#8862)
Browse files Browse the repository at this point in the history
  • Loading branch information
banool authored and gedigi committed Aug 2, 2023
1 parent ac77950 commit a2eee28
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions aptos-move/framework/src/built_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item = &CompiledModule> {
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()
Expand Down

0 comments on commit a2eee28

Please sign in to comment.