Elixir-friendly builders for Rust fragments.
Use this module when generating Rust declarations from data. Builders return small structs or fragments that RustQ can validate and splice into templates.
alias RustQ.Rust
Rust.struct(:User,
vis: :pub,
derive: [:Clone, :Debug],
fields: [Rust.field(:id, :i64, vis: :pub)]
)Prefer real Rust templates for larger bodies and use these builders for the repetitive edges: fields, function signatures, attributes, type aliases, and simple declarations.
Summary
Types
Functions
@spec arg(RustQ.Rust.Function.t(), term()) :: RustQ.Rust.Function.t()
@spec arg(atom() | String.t(), rust_type()) :: RustQ.Rust.Fragment.t()
@spec arg(RustQ.Rust.Function.t(), atom() | String.t(), rust_type(), keyword()) :: RustQ.Rust.Function.t()
@spec args(RustQ.Rust.Function.t(), [term()]) :: RustQ.Rust.Function.t()
@spec arm(iodata()) :: RustQ.Rust.Fragment.t()
@spec arm(iodata(), iodata()) :: RustQ.Rust.Fragment.t()
@spec assign(iodata(), iodata()) :: RustQ.Rust.Fragment.t()
@spec ast_item(term()) :: RustQ.Rust.Fragment.t()
@spec ast_items([term()]) :: [RustQ.Rust.Fragment.t()]
@spec body(RustQ.Rust.Function.t(), iodata()) :: RustQ.Rust.Function.t()
@spec call_expr(iodata(), atom() | String.t(), [iodata()]) :: RustQ.Rust.Fragment.t()
@spec call_stmt(iodata(), atom() | String.t(), [iodata()]) :: RustQ.Rust.Fragment.t()
@spec cast(iodata(), iodata()) :: RustQ.Rust.Fragment.t()
@spec derive( RustQ.Rust.Struct.t() | RustQ.Rust.EnumDecl.t(), atom() | String.t() | [atom() | String.t()] ) :: RustQ.Rust.Struct.t() | RustQ.Rust.EnumDecl.t()
@spec enum( atom() | String.t(), keyword() ) :: RustQ.Rust.EnumDecl.t()
@spec expr(iodata()) :: RustQ.Rust.Fragment.t()
@spec field(atom() | String.t(), rust_type()) :: RustQ.Rust.Field.t()
@spec field(atom() | String.t(), rust_type(), keyword()) :: RustQ.Rust.Field.t()
@spec field(RustQ.Rust.Struct.t(), atom() | String.t(), rust_type(), keyword()) :: RustQ.Rust.Struct.t()
@spec fields(RustQ.Rust.Struct.t(), [term()]) :: RustQ.Rust.Struct.t()
Alias for fn_/2, callable as RustQ.Rust.fn(...).
@spec fn_( atom() | String.t(), keyword() ) :: RustQ.Rust.Function.t()
@spec if_(iodata(), [term()], keyword()) :: RustQ.Rust.Fragment.t()
@spec if_let(iodata(), iodata(), [term()], keyword()) :: RustQ.Rust.Fragment.t()
@spec impl( rust_type(), keyword() ) :: RustQ.Rust.Impl.t()
@spec impl_item(iodata()) :: RustQ.Rust.Fragment.t()
@spec item(iodata()) :: RustQ.Rust.Fragment.t()
@spec item(RustQ.Rust.Impl.t() | RustQ.Rust.ModDecl.t(), term()) :: RustQ.Rust.Impl.t() | RustQ.Rust.ModDecl.t()
@spec items(RustQ.Rust.Impl.t() | RustQ.Rust.ModDecl.t(), [term()]) :: RustQ.Rust.Impl.t() | RustQ.Rust.ModDecl.t()
@spec let_(iodata(), iodata()) :: RustQ.Rust.Fragment.t()
@spec let_mut(iodata(), iodata()) :: RustQ.Rust.Fragment.t()
@spec match_(iodata(), [{iodata(), [term()]}]) :: RustQ.Rust.Fragment.t()
@spec mod( atom() | String.t(), keyword() ) :: RustQ.Rust.ModDecl.t()
@spec none() :: RustQ.Rust.Fragment.t()
@spec param(atom() | String.t(), rust_type()) :: RustQ.Rust.Fragment.t()
@spec prelude(atom()) :: [RustQ.Rust.Use.t()]
@spec question(iodata()) :: RustQ.Rust.Fragment.t()
@spec raw(iodata()) :: RustQ.Rust.Fragment.t()
@spec ref_expr( iodata(), keyword() ) :: RustQ.Rust.Fragment.t()
@spec return_if(iodata(), iodata()) :: RustQ.Rust.Fragment.t()
@spec returns(RustQ.Rust.Function.t(), rust_type()) :: RustQ.Rust.Function.t()
@spec some(iodata()) :: RustQ.Rust.Fragment.t()
@spec stmt(iodata()) :: RustQ.Rust.Fragment.t()
@spec struct( atom() | String.t(), keyword() ) :: RustQ.Rust.Struct.t()
@spec trait(RustQ.Rust.Impl.t(), rust_type()) :: RustQ.Rust.Impl.t()
@spec tuple([iodata()]) :: RustQ.Rust.Fragment.t()
@spec type_alias(atom() | String.t(), rust_type(), keyword()) :: RustQ.Rust.TypeAlias.t()
@spec use( term(), keyword() ) :: RustQ.Rust.Use.t()
@spec use_many( [term()], keyword() ) :: [RustQ.Rust.Use.t()]
@spec variant(RustQ.Rust.EnumDecl.t(), term()) :: RustQ.Rust.EnumDecl.t()
@spec variants(RustQ.Rust.EnumDecl.t(), [term()]) :: RustQ.Rust.EnumDecl.t()