def width_of

bolt@1.27.0.0 · src/rules/style/space.bend:34

import bolt@1.27.0.0/src/rules/style/space.bend as Space
import Base
import bolt@1.27.0.0/src/syntax/lex.bend as Lex

34# a token's share of its line's width; a `#|` trailer line counts nothing
35def width_of(kk: Lex.TokKind, +tt: String) -> U32:
36  match kk:
37    case Lex.TStr{}:
38      2
39    case Lex.TNewline{}:
40      0
41    case Lex.TComment{}:
42      Bool.pick(U32, String.starts_with(tt, "#|"), 0, U32.from_nat(String.length(tt)))
43    case other:
44      U32.from_nat(String.length(tt))

Uses (7)

Used by (2)