ListRulesForBranchIter returns an iterator that paginates through all results of ListRulesForBranch. Note that since [BranchRules] contains a large number of slices, this iterator returns type `any` and it is therefore the responsibility of the caller to perform a type switch to determine what item
(ctx context.Context, owner, repo, branch string, opts *ListOptions)
| 44 | // returns type `any` and it is therefore the responsibility of the caller to perform a |
| 45 | // type switch to determine what item is being returned for each iteration. |
| 46 | func (s *RepositoriesService) ListRulesForBranchIter(ctx context.Context, owner, repo, branch string, opts *ListOptions) iter.Seq2[any, error] { |
| 47 | return func(yield func(any, error) bool) { |
| 48 | // Create a copy of opts to avoid mutating the caller's struct |
| 49 | if opts == nil { |
| 50 | opts = &ListOptions{} |
| 51 | } else { |
| 52 | opts = Ptr(*opts) |
| 53 | } |
| 54 | |
| 55 | for { |
| 56 | results, resp, err := s.ListRulesForBranch(ctx, owner, repo, branch, opts) |
| 57 | if err != nil { |
| 58 | yield(nil, err) |
| 59 | return |
| 60 | } |
| 61 | |
| 62 | // Now iterate through ALL possible results from [BranchRules]. |
| 63 | for _, item := range results.Creation { |
| 64 | if !yield(item, nil) { |
| 65 | return |
| 66 | } |
| 67 | } |
| 68 | for _, item := range results.Update { |
| 69 | if !yield(item, nil) { |
| 70 | return |
| 71 | } |
| 72 | } |
| 73 | for _, item := range results.Deletion { |
| 74 | if !yield(item, nil) { |
| 75 | return |
| 76 | } |
| 77 | } |
| 78 | for _, item := range results.RequiredLinearHistory { |
| 79 | if !yield(item, nil) { |
| 80 | return |
| 81 | } |
| 82 | } |
| 83 | for _, item := range results.MergeQueue { |
| 84 | if !yield(item, nil) { |
| 85 | return |
| 86 | } |
| 87 | } |
| 88 | for _, item := range results.RequiredDeployments { |
| 89 | if !yield(item, nil) { |
| 90 | return |
| 91 | } |
| 92 | } |
| 93 | for _, item := range results.RequiredSignatures { |
| 94 | if !yield(item, nil) { |
| 95 | return |
| 96 | } |
| 97 | } |
| 98 | for _, item := range results.PullRequest { |
| 99 | if !yield(item, nil) { |
| 100 | return |
| 101 | } |
| 102 | } |
| 103 | for _, item := range results.RequiredStatusChecks { |