def push_room_at

bend-collections@1.0.0.0 · src/containers/dynamic_array.bend:360

import bend-collections@1.0.0.0/src/containers/dynamic_array.bend as DynamicArray
import Base
import bend-collections@1.0.0.0/src/containers/types/dynamic_array.bend as E

360def push_room_at(~T: Data, limit: Nat, +depth: Nat, +cap: Nat, +len: Nat, arr: Array<Maybe<&2, T>>, v: T, room: Bool, grow: Bool) -> DynArray<&2, T> & Result<&2, &2, E.Error, Unit>:
361  match room grow:
362    case True{} _:
363      (DA{limit, depth, cap, 1n+len, Array.set(Maybe<&2, T>, arr, U32.from_nat(len), Some{v})}, Done{Unit{}})
364    case False{} True{}:
365      (DA{limit, 1n+depth, Nat.double(cap), 1n+len, Array.set(Maybe<&2, T>, grown_at(~T, depth, arr), U32.from_nat(len), Some{v})}, Done{Unit{}})
366    case False{} False{}:
367      (DA{limit, depth, cap, len, arr}, Fail{E.CapacityExceeded{}})

Uses (14)

Used by (1)