Skip to main content
Log in

Mojo trait

EqualityComparableWritableCollectionElementNew

A trait that combines the CollectionElement, Writable and EqualityComparable traits.

This trait requires types to implement CollectionElement, Writable and EqualityComparable interfaces, allowing them to be used in collections, compared, and written to output.

Implemented traits

AnyType, CollectionElementNew, EqualityComparable, ExplicitlyCopyable, Movable, UnknownDestructibility, Writable, WritableCollectionElementNew

Methods

__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.

__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.

copy

copy(self: _Self) -> _Self

Explicitly construct a copy of self.

Returns:

A copy of this value.

write_to

write_to[W: Writer](self: _Self, mut writer: W)

Formats the string representation of this type to the provided Writer.

Parameters:

  • W (Writer): A type conforming to the Writable trait.

Args:

  • writer (W): The type conforming to Writable.