Skip to main content

Mojo module

traits

Compile-time meta functions for checking trait conformance across variadic type lists.

comptime values

AllCopyable

comptime AllCopyable[*Ts: AnyType] = #kgen.param_list.reduce(Ts, base=True, reducer=[PrevV: KGENParamList[Bool], VA: KGENParamList[AnyType], idx: __mlir_type.index] PrevV[0] if conforms_to(VA[idx], AnyType & Copyable & Movable) else conforms_to(VA[idx], AnyType & Copyable & Movable))[0]

Evaluates to True if all types in Ts conform to Copyable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to Copyable.

AllDefaultable

comptime AllDefaultable[*Ts: AnyType] = #kgen.param_list.reduce(Ts, base=True, reducer=[PrevV: KGENParamList[Bool], VA: KGENParamList[AnyType], idx: __mlir_type.index] PrevV[0] if conforms_to(VA[idx], AnyType & ImplicitlyDestructible & Defaultable) else conforms_to(VA[idx], AnyType & ImplicitlyDestructible & Defaultable))[0]

Evaluates to True if all types in Ts conform to Defaultable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to Defaultable.

AllEquatable

comptime AllEquatable[*Ts: AnyType] = #kgen.param_list.reduce(Ts, base=True, reducer=[PrevV: KGENParamList[Bool], VA: KGENParamList[AnyType], idx: __mlir_type.index] PrevV[0] if conforms_to(VA[idx], AnyType & ImplicitlyDestructible & Equatable) else conforms_to(VA[idx], AnyType & ImplicitlyDestructible & Equatable))[0]

Evaluates to True if all types in Ts conform to Equatable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to Equatable.

AllHashable

comptime AllHashable[*Ts: AnyType] = #kgen.param_list.reduce(Ts, base=True, reducer=[PrevV: KGENParamList[Bool], VA: KGENParamList[AnyType], idx: __mlir_type.index] PrevV[0] if conforms_to(VA[idx], AnyType & Hashable) else conforms_to(VA[idx], AnyType & Hashable))[0]

Evaluates to True if all types in Ts conform to Hashable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to Hashable.

AllImplicitlyCopyable

comptime AllImplicitlyCopyable[*Ts: AnyType] = #kgen.param_list.reduce(Ts, base=True, reducer=[PrevV: KGENParamList[Bool], VA: KGENParamList[AnyType], idx: __mlir_type.index] PrevV[0] if conforms_to(VA[idx], AnyType & ImplicitlyDestructible & Copyable & ImplicitlyCopyable & Movable) else conforms_to(VA[idx], AnyType & ImplicitlyDestructible & Copyable & ImplicitlyCopyable & Movable))[0]

Evaluates to True if all types in Ts conform to ImplicitlyCopyable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to ImplicitlyCopyable.

AllImplicitlyDestructible

comptime AllImplicitlyDestructible[*Ts: AnyType] = #kgen.param_list.reduce(Ts, base=True, reducer=[PrevV: KGENParamList[Bool], VA: KGENParamList[AnyType], idx: __mlir_type.index] PrevV[0] if conforms_to(VA[idx], AnyType & ImplicitlyDestructible) else conforms_to(VA[idx], AnyType & ImplicitlyDestructible))[0]

Evaluates to True if all types in Ts conform to ImplicitlyDestructible, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to ImplicitlyDestructible.

AllMovable

comptime AllMovable[*Ts: AnyType] = #kgen.param_list.reduce(Ts, base=True, reducer=[PrevV: KGENParamList[Bool], VA: KGENParamList[AnyType], idx: __mlir_type.index] PrevV[0] if conforms_to(VA[idx], AnyType & Movable) else conforms_to(VA[idx], AnyType & Movable))[0]

Evaluates to True if all types in Ts conform to Movable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to Movable.

AllRegisterPassable

comptime AllRegisterPassable[*Ts: AnyType] = #kgen.param_list.reduce(Ts, base=True, reducer=[PrevV: KGENParamList[Bool], VA: KGENParamList[AnyType], idx: __mlir_type.index] PrevV[0] if conforms_to(VA[idx], AnyType & Movable & RegisterPassable) else conforms_to(VA[idx], AnyType & Movable & RegisterPassable))[0]

Evaluates to True if all types in Ts conform to RegisterPassable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to RegisterPassable.

AllWritable

comptime AllWritable[*Ts: AnyType] = #kgen.param_list.reduce(Ts, base=True, reducer=[PrevV: KGENParamList[Bool], VA: KGENParamList[AnyType], idx: __mlir_type.index] PrevV[0] if conforms_to(VA[idx], AnyType & ImplicitlyDestructible & Writable) else conforms_to(VA[idx], AnyType & ImplicitlyDestructible & Writable))[0]

Evaluates to True if all types in Ts conform to Writable, False otherwise.

Parameters

  • *Ts (AnyType): The types to check for conformance to Writable.

Was this page helpful?