Skip to main content
Log in

Mojo trait

BoolableKeyElement

The BoolableKeyElement trait denotes a trait composition of the Boolable and KeyElement traits.

This is useful to have as a named entity since Mojo does not currently support anonymous trait compositions to constrain on Boolable & KeyElement in the parameter.

Implemented traits

AnyType, Boolable, CollectionElement, Copyable, EqualityComparable, Hashable, KeyElement, Movable, UnknownDestructibility

Methods

__copyinit__

__copyinit__(out self: _Self, existing: _Self, /)

Create a new instance of the value by copying an existing one.

Args:

  • existing (_Self): The value to copy.

__moveinit__

__moveinit__(out self: _Self, owned existing: _Self, /)

Create a new instance of the value by moving the value of another.

Args:

  • existing (_Self): The value to move.

__bool__

__bool__(self: _Self) -> Bool

Get the boolean representation of the value.

Returns:

The boolean representation of the value.

__eq__

__eq__(self: _Self, other: _Self) -> Bool

Define whether two instances of the object are equal to each other.

Args:

  • other (_Self): Another instance of the same type.

Returns:

True if the instances are equal according to the type's definition of equality, False otherwise.

__ne__

__ne__(self: _Self, other: _Self) -> Bool

Define whether two instances of the object are not equal to each other.

Args:

  • other (_Self): Another instance of the same type.

Returns:

True if the instances are not equal according to the type's definition of equality, False otherwise.

__hash__

__hash__(self: _Self) -> UInt

Return a 64-bit hash of the type's data.

Returns:

A 64-bit integer hash of this instance's data.