def take_to.go

bend-net-url@0.4.0.0 · url.bend:151

import bend-net-url@0.4.0.0/url.bend as Url
import Base

151# hit: the last char pushed onto acc was the stop char.
152def take_to.go(s: String, +stop: U32, acc: String, hit: Bool) -> String & String:
153  match s:
154    case SNil{}:
155      match hit:
156        case True{}:
157          take.cut(acc, SNil{})
158        case False{}:
159          (String.reverse(acc), SNil{})
160    case SCon{Chr{+c}, t}:
161      match hit:
162        case True{}:
163          take.cut(acc, SCon{Chr{c}, t})
164        case False{}:
165          take_to.go(t, stop, SCon{Chr{c}, acc}, U32.is_eq(c, stop))

Uses (9)

Used by (1)