You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
for (k, v) in a BTreeMap: 'tuple pattern requires tuple subject' (D44 traversal non-compliance on BTreeMap) #1561
Found while implementing D61 (#1480); present on the installed v0.15.2.1 and main.
use std.collections.BTreeMap
fn main:
var bt: BTreeMap[i32, str] = BTreeMap.new()
bt.insert(10, "ten")
for (k, v) in bt:
print(f"{k} {v}")
error: tuple pattern requires tuple subject
The same loop over a HashMap works. D44 (decisions.md) says for (k, v) in map is map.iter() binding &K/&V for maps; BTreeMap implements Iterable[(K, V)] over its Vec[(K, V)] and the tuple pattern does not bind. In a generic body (fn f[K: Ord, V](m: &BTreeMap[K, V])) the bindings come back as undefined variables instead. D61 BTreeMap formatting iterates by index (key_at/value_at) until this is fixed.
Activity
Sema/MIR: `for (k, v) in bt` traverses a BTreeMap in place (D44, #1561)