Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Iterator over a Model #232

Merged
merged 2 commits into from
Apr 5, 2023
Merged

Conversation

Pat-Lafon
Copy link
Contributor

One nice abstraction that the python bindings implement is to be able to iterate over a Model. One can then use the features added in #221 to get the interpretations that the Model assigns for these declarations.

If this is worth adding, the implementation comes from https://z3prover.github.io/api/html/classz3py_1_1_model_ref.html#a7890b7c9bc70cf2a26a343c22d2c8367 where they hook into Python's __len__ and __getitem__ to extract all consts and funcs from a model when using a for loop. I think the only difference here is that for Rust we need to manage a struct that does the iteration, here ModelIter(akin to https://doc.rust-lang.org/std/slice/struct.Iter.html) which contains the current index into the model and the total length.

The testcase is related to #221.

@waywardmonkeys waywardmonkeys merged commit a7418da into prove-rs:master Apr 5, 2023
@waywardmonkeys
Copy link
Contributor

Thanks!

@Pat-Lafon Pat-Lafon deleted the iter branch April 5, 2023 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants