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 toCopyable.
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 toDefaultable.
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 toEquatable.
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 toHashable.
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 toImplicitlyCopyable.
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 toImplicitlyDestructible.
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 toMovable.
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 toRegisterPassable.
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 toWritable.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!