def text.truncate

ezsys@0.1.0.0 · src/str.bend:445

import ezsys@0.1.0.0/src/str.bend as Str
import Base

445# the first `n` code points of the text, or all of it when it is shorter
446def text.truncate(txt: String, width: Nat) -> String:
447  match txt width:
448    case SNil{} _:
449      SNil{}
450    case SCon{_h, _t} 0n:
451      SNil{}
452    case SCon{h, t} 1n+k:
453      SCon{h, text.truncate(t, k)}

Uses (2)

Used by (1)