Struct hcl::eval::FuncDefBuilder

source ·
pub struct FuncDefBuilder { /* private fields */ }
Expand description

A builder for FuncDef values.

The builder is created by the .builder() method of FuncDef.

See the type-level documentation of FuncDef and builder method docs for usage examples.

Implementations§

Adds a function parameter.

Calls to .param() and .params() can be mixed and will always add more parameters to the function definition instead of overwriting existing ones.

Examples
let func_def = FuncDef::builder()
    .param(ParamType::String)
    .build(strlen);

Adds function parameters from an iterator.

Calls to .params() and .param() can be mixed and will always add more parameters to the function definition instead of overwriting existing ones.

Examples
let func_def = FuncDef::builder()
    .params([
        ParamType::Number,
        ParamType::Number,
        ParamType::Number,
    ])
    .build(add3);

Adds a variadic parameter to the function definition.

Only one variadic parameter can be added. Subsequent invocation of this method will overwrite a previously set variadic parameter.

Examples
let func_def = FuncDef::builder()
    .param(ParamType::String)
    .variadic_param(ParamType::Any)
    .build(printf);

Takes ownership of the builder and builds the FuncDef for the provided function and the contents of the builder.

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.