IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

traits

Core object-lifetime and value-semantics traits.

The traits package defines the stabilized traits that describe how Mojo values are created, copied, moved, and destroyed: AnyType, Deinitable, Movable, Copyable, and ImplicitlyCopyable. These traits are Mojo built-ins and are automatically imported into every Mojo program through the prelude.

Modules

  • anytype: Defines AnyType, the most basic trait that all Mojo types extend by default.
  • copyable: Defines Copyable and ImplicitlyCopyable, the traits for types whose value can be copied.
  • deinitable: Defines Deinitable, the trait for types with lifetime management through destructors.
  • movable: Defines Movable, the trait for types whose value can be moved.