def TraceState.set
import bend-trace-context@0.2.0.0/trace_context.bend as TraceContextimport Base
2359# Add or update the entry of `key` (W3C 3.5): it goes to the front with
2360# `value`, and the other entries follow in their order. At most 31 of them
2361# stay, so a new key in a full state removes the last entry, while updating a
2362# key that is present evicts nothing (laws set_entries, update_keeps_all,
2363# insert_entries and set_get).
2364def TraceState.set(+state: TraceState, +key: StateKey, value: StateValue) -> TraceState:
2365 TraceState.from_entries(Con{StateEntry{key, value},
2366 List.take(&2, StateEntry, Entries.without(TraceState.entries(state), StateKey.to_string(key)), 31n)}, state)