FnDecl
class FnDecl Import
Source: use macro::{FnDecl}; compiler/src/prelude/macro.hy A function or method handed to an attribute macro.
Fields#
| Field | Type | Description |
|---|---|---|
name | Ident | |
params | Vec<Param> | |
ret | TypeRef | Return type as written, or unit when the function declares none. |
type_params | Vec<Ident> | |
attrs | Vec<Attr> | Remaining attributes (the macro’s own attribute is removed). |
owner | string | Owning class for an impl method, else "". |
is_pub | bool | pub (methods; top-level functions are always visible). |
is_static | bool | |
is_coro | bool | |
declares_effects | bool | Declares its effects: pure fn or uses {…}. |
is_pure | bool | Spelled pure fn. |
effects | Vec<string> | The names in uses {…}: read, write, net, env, exec, ffi, thread, suspend, mutate. |
requires | Vec<string> | requires clauses as written after the keyword (n >= 0 or n >= 0, "message"), in order. |
ensures | Vec<string> | ensures clauses, like requires. |
docs | Vec<string> | |
body | string | The body block as written, braces included. |
source | string | The whole declaration as written (the macro’s own attribute removed). |
Methods#
| Name | Description |
|---|---|
body_source | |
signature | name(T a, U b) -> R: the signature as written, under a new name. |
with_name | The function under another name, with its remaining attributes: #[other] pub fn name(T a) -> R { body }. |
contract_clauses | The requires / ensures clauses, each as requires … (empty when there are none). |
uses_clause | uses {read, write} as declared (uses {} for none). |
call | A call of name with this function’s arguments (self.name(a, b) for an instance method). |
arg_names | a, b: the parameter names, for forwarding a call. |