From a8e153d90d291d985ff7fa0a56634b32719b90ad Mon Sep 17 00:00:00 2001 From: Pedro Fontana Date: Wed, 31 May 2023 13:03:19 -0300 Subject: [PATCH] Add Program.builtins_len() method (#1194) * Add Program.builtins_len() method * Update CHANGELOG.md --- CHANGELOG.md | 2 ++ src/types/program.rs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49f3e07dec..e6caa98552 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## Cairo-VM Changelog #### Upcoming Changes +* Add `Program::builtins_len method` [#1194](https://github.com/lambdaclass/cairo-rs/pull/1194) + * fix: Handle the deserialization of serde_json::Number with scientific notation (e.g.: Number(1e27)) in felt_from_number function [#1188](https://github.com/lambdaclass/cairo-rs/pull/1188) * bugfix: Use cairo constants in `ASSERT_250_BIT` hint [#1187](https://github.com/lambdaclass/cairo-rs/pull/1187) diff --git a/src/types/program.rs b/src/types/program.rs index a9677e4259..8bb7ffdf87 100644 --- a/src/types/program.rs +++ b/src/types/program.rs @@ -125,6 +125,10 @@ impl Program { self.shared_program_data.data.len() } + pub fn builtins_len(&self) -> usize { + self.builtins.len() + } + pub fn get_identifier(&self, id: &str) -> Option<&Identifier> { self.shared_program_data.identifiers.get(id) } @@ -351,6 +355,8 @@ mod tests { program.iter_builtins().cloned().collect::>(), builtins ); + + assert_eq!(program.builtins_len(), 2); } #[test]