Entry::or_default and Seq::cloned Are in stdStatus: Accepted (#1082)
Date: October 31, 2026 (architect’s decision under the owner’s rule of
2026-10-31, docs/supervisor.md, Language decisions: an obvious std
counterpart of a Rust call is the architect’s)
Answers: two Rust calls the C1a move (contracts/mod.rs) needs and
std lacks: .entry(k).or_default() and iter().cloned() (both NK1171
today)
Related: ADR-collections-1 (the maps’ entries,
D4 the copy of each element), ADR-282 D7/D9 (.clone() is
the program’s copy), Part III 17.1 (std::collections, Seq[T]),
Part III 17 (every Rust std call a move moves has a counterpart)
The C1a move wrote or_insert_with(fn() { collections::BTreeSet() }) for
Rust’s or_default() and .map(fn(p) { p.clone() }) for .cloned(). Both
are ways around a missing entry (CLAUDE.md, A missing form stops the
work). Are the two entries in std, and what do they mean?
Entry::or_default() puts in the value made with no argumentsm.entry(k).or_default() is m.entry(k).or_insert_with(fn { V() }): the
value that is there, putting in first the one that V() makes where there is
none. It is on both maps, as or_insert_with is (ADR-collections-1). It is
offered where V can be made with no arguments: a collection, String
(empty), a number (0), bool (false), and a struct every field of which has a
default. For another V the call is refused, with the code that refuses a
call whose type does not fit (no new code); its help names or_insert_with.
It runs nothing of the program’s, so it never pauses (sync = true).
Seq::cloned() hands on a copy of each elementxs.iter().cloned() is xs.iter().map fn(x) { x.clone() }: a sequence of
owned T, each element the program’s copy (ADR-282 D7), as
s.extend(xs.clone()) copies each element (ADR-collections-1 D4). On a
sequence whose elements are views it lowers to Rust’s cloned(); on one whose
elements are already owned, to the map it means, or to nothing where the
compiler knows nothing else holds them. It passes sync, pauses, throws,
ends and sized through as map does.
or_default is or_insert_with with the constructor the
language already writes as V(); cloned is the .clone() each element
already takes, said once for the whole sequence, as extend says it.Entry::or_default, Iterator::cloned,
with copied beside it). Nikaia keeps one word, since it does not split
Copy from Clone in what a program writes.copied (one word is enough, D2); Option::cloned (no move has met it).