MyPair

MyPair

Mojo struct 🡭

MyPair

@memory_only
struct MyPair[T: Intable]

A simple example struct.

This struct is re-exported by its parent package, so shows up where the user expects it due to the import path. It has aliases, parameters, fields and methods.

Linking to individual members is as easy as this:

Method: [.MyPair.dump], field: [.MyPair.first].

which gives:

Method: MyPair.dump, field: MyPair.first.

Aliases

  • MyInt = Int: An example struct alias. Alias for MyIntAlias

Parameters

  • T (Intable): The MyPair’s element type.

Fields

  • first (T): First struct field.
  • second (T): Second struct field.

Implemented traits

AnyType, UnknownDestructibility

Methods

 

__init__

fn __init__(out self, first: T, second: T)

Creates a new MyPair. Args:

Returns:

Self

dump

fn dump(self)

Prints fields first and second. Args:

  • self (Self)

format

fn format(self, fmt: String) -> String

Formats this MyPair. A longer description of the method, explaining how to use it.

Args:

  • self (Self)
  • fmt (String): Desired output format.

Returns:

String: A formatted string.

Raises:

When called with an unknown fmt argument.

static_method

@staticmethod
fn static_method(self)

Details Args:

  • self (Self)