-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There are two existing patterns for constructing a gate from a set of constraints with a common selector: - Create an iterator of constraints, where each constraint includes the selector: ``` vec![ ("foo", selector.clone() * foo), ("bar", selector.clone() * bar), ("baz", selector * bar), ] ``` This requires the user to write O(n) `selector.clone()` calls. - Create an iterator of constraints, and then map the selector in: ``` vec![ ("foo", foo), ("bar", bar), ("baz", bar), ].into_iter().map(move |(name, poly)| (name, selector.clone() * poly)) ``` This looks cleaner overall, but the API is not as intuitive, and it is messier when the constraints are named. The `Constraints` struct provides a third, clearer API: ``` Constraints::with_selector( selector, vec![ ("foo", foo), ("bar", bar), ("baz", bar), ], ) ``` This focuses on the structure of the constraints, and handles the selector application for the user.
- Loading branch information
Showing
3 changed files
with
131 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters