Module
std::meta::module
contains methods on the built-in Module
type which represents a module in the source program.
Note that this type represents a module generally, it isn't limited to only mod my_submodule { ... }
declarations in the source program.
Methods
add_item
add_item
comptime fn add_item(self, item: Quoted) {}
Adds a top-level item (a function, a struct, a global, etc.) to the module.
Adding multiple items in one go is also valid if the Quoted
value has multiple items in it.
Note that the items are type-checked as if they are inside the module they are being added to.
name
name
comptime fn name(self) -> Quoted {}
Returns the name of the module.
functions
functions
comptime fn functions(self) -> [FunctionDefinition] {}
Returns each function in the module.
has_named_attribute
has_named_attribute
comptime fn has_named_attribute(self, name: Quoted) -> bool {}
Returns true if this module has a custom attribute with the given name.
is_contract
is_contract
comptime fn is_contract(self) -> bool {}
true
if this module is a contract module (was declared via contract foo { ... }
).