pub fn snapshot(
callable: &mut dyn Callable,
value: &Value,
span: Span,
) -> Result<Value, RuntimeError>Expand description
The independent copy Snapshot makes of a value that no declared
conformance answers for.
The Language Reference makes an independent copy an explicit impl Snapshot for Type, and this is everything that decision leaves over: a
value with nothing mutable inside it returns itself, because a copy of it
is not observable, and a Vector — the one thing a copy is observable of
— allocates storage of its own and snapshots what it held.
An Array, a Map and a Set are cloned rather than walked, which is
Interpreter::snapshot’s own answer and not a shortcut taken here: each
is immutable, so an element that shares storage with something else went
on sharing it before this was called and there is nothing for a copy to
separate.
A struct, an enum and a dyn are not here. They are what the caller
answers, through Callable::snapshot.