def literal

bolt@1.27.0.0 · src/rules/perf/strings.bend:47

import bolt@1.27.0.0/src/rules/perf/strings.bend as Strings
import Base
import bolt@1.27.0.0/src/syntax/lex.bend as Lex
import bolt@1.27.0.0/src/syntax/tree.bend as Tree
import bolt@1.27.0.0/src/rules/tokens.bend as T

47# the characters of the string a case pattern opens with, if it does and the
48# string is closed
49def literal(kids: Tree.Node) -> Maybe<&2, U32>:
50  match kids:
51    case Tree.NCons{Tree.Leaf{Lex.Tok{Lex.TStr{}, +t, l, c}}, rest}:
52      +w = T.width(t)
53      Bool.pick(Maybe<&2, U32>, terminated(t), Some{(w - 2 : U32)}, None{})
54    case other:
55      None{}

Uses (9)

Used by (1)