def text.truncate
import ezsys@0.1.0.0/src/str.bend as Strimport 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)}