def Carrier.named

bend-trace-context@0.2.0.0 · trace_context.bend:2718

import bend-trace-context@0.2.0.0/trace_context.bend as TraceContext
import Base

2718# Whether `text` is `name` without regard to ASCII case (W3C 3.2.1 and
2719# 3.3.1): each character of `text`, with the letters A to Z lowered, is the
2720# character of `name` at its position. Other characters are compared as they
2721# are, so a name that differs by more than ASCII case names another field.
2722# `name` is written in lowercase, and the comparison follows it, so a long
2723# field name is not read past it.
2724def Carrier.named(name: String, text: String) -> Bool:
2725  match name text:
2726    case SNil{} SNil{}:
2727      True{}
2728    case SNil{} SCon{char, rest}:
2729      False{}
2730    case SCon{expected, more} SNil{}:
2731      False{}
2732    case SCon{expected, more} SCon{char, rest}:
2733      Bool.and(Char.is_eq(Char.to_lower(char), expected), Carrier.named(more, rest))

Uses (5)

Used by (2)