-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Iterator trait for Fragment and BoundedVec (#327)
This PR creates Iterator trait with one function: `for_each` and implements it for Fragment and BoundedVec. It also migrates the code to use `for_each` where possible. I only found 2 places (1 for Fragment and 1 for BoundedVec) where it's possible to use it. In the rest of the loops iterating over fragments or boundedvecs `i` (loop iterator) is used in some way that makes it impossible to use `for_each`.
- Loading branch information
Showing
4 changed files
with
33 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ mod types; | |
mod option; | ||
mod bytes32; | ||
mod bytes32_test; | ||
mod iterator; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
trait Iterator<T> { | ||
fn for_each<Env>(self, f: fn[Env](T) -> ()); | ||
} |