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).
InlineLevel
struct InlineLevel
Names the levels the @inline decorator accepts.
@inline takes one of these, so a misspelling is caught where it is
written, and a comptime expression can choose a level per instantiation:
@inline(.always)
def doubled(x: Int) -> Int:
return x * 2
@inline(policy)
def scaled[policy: InlineLevel](x: Int) -> Int:
return x * 3
def main():
print(doubled(1) + scaled[.never](2))
Implemented traits
AnyType,
Copyable,
Deinitable,
Equatable,
ImplicitlyCopyable,
Movable,
RegisterPassable,
TrivialRegisterPassable
comptime members
always
comptime always = InlineLevel(value=Int(1))
Always inlines the function.
automatic
comptime automatic = InlineLevel(value=Int(0))
Leaves the decision to the compiler's heuristics.
never
comptime never = InlineLevel(value=Int(4))
Never inlines the function.
nodebug
comptime nodebug = InlineLevel(value=Int(2))
Always inlines the function, and drops its debug info when inlining.
Methods
__eq__
def __eq__(self, rhs: Self) -> Bool
Compare two levels.
Args:
- rhs (
Self): The level to compare against.
Returns:
Bool: True if the levels are the same.