all returns an iterator that yields all key-value pairs in the Attributes chain. If a key appears multiple times, only the most recently added value is yielded.
()
| 159 | // chain. If a key appears multiple times, only the most recently added value |
| 160 | // is yielded. |
| 161 | func (a *Attributes) all() iter.Seq2[any, any] { |
| 162 | return func(yield func(any, any) bool) { |
| 163 | seen := map[any]bool{} |
| 164 | for cur := a; cur != nil; cur = cur.parent { |
| 165 | if seen[cur.key] { |
| 166 | continue |
| 167 | } |
| 168 | if !yield(cur.key, cur.value) { |
| 169 | return |
| 170 | } |
| 171 | seen[cur.key] = true |
| 172 | } |
| 173 | } |
| 174 | } |