NamedRecord

vecxt_re.NamedRecord
object NamedRecord

Compile-time helpers for accepting a named tuple by field name rather than by field position.

A caller may supply (id = "1", price = p, notional = n, name = "A") where the required shape is (price: Price, notional: CurrencyAmount, name: String, id: String): field order is irrelevant and extra fields are ignored, but every required field must be present with a conforming type or compilation fails.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

sealed trait Missing

Marker produced by Lookup when a field name is absent.

Marker produced by Lookup when a field name is absent.

Attributes

Supertypes
class Object
trait Matchable
class Any

Types

type Lookup[N <: Tuple, V <: Tuple, K] = (N, V) match { case (K *: _$1, v *: _$2) => v case (_$3 *: ns, _$4 *: vs) => Lookup[ns, vs, K] case (EmptyTuple, EmptyTuple) => Missing }

The value type of field K in the named tuple with names N and values V, or Missing.

The value type of field K in the named tuple with names N and values V, or Missing.

Attributes

Value members

Concrete methods

inline def check[N <: Tuple, V <: Tuple, Required <: AnyNamedTuple]: Unit

Fails compilation unless the named tuple (N, V) has every field of Required with a conforming type.

Fails compilation unless the named tuple (N, V) has every field of Required with a conforming type.

An unconstrained N (inferred as Tuple when passing Nil) is accepted, as there are no values to check.

Attributes

inline def names[N <: Tuple]: List[String]

The field names of N as runtime strings; empty for an unconstrained N (see check).

The field names of N as runtime strings; empty for an unconstrained N (see check).

Attributes

def toMap[N <: Tuple, V <: Tuple](names: List[String], nt: NamedTuple[N, V]): Map[String, Any]

Zips pre-computed field names with the values of nt into a name -> value map.

Zips pre-computed field names with the values of nt into a name -> value map.

Attributes