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§

source§

impl FuncDefBuilder

source

pub fn param(self, param: ParamType) -> FuncDefBuilder

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);
source

pub fn params<I>(self, params: I) -> FuncDefBuilder
where I: IntoIterator<Item = ParamType>,

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);
source

pub fn variadic_param(self, param: ParamType) -> FuncDefBuilder

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);
source

pub fn build(self, func: Func) -> FuncDef

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

Trait Implementations§

source§

impl Debug for FuncDefBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.