pub struct TypeBuilder<T>where
    T: ?Sized,
{ /* private fields */ }
Expand description

A builder that allows for binding APIs with user-defined types.

Implementations

Creates a new TypeBuilder.

Adds a raw instance function to the type.

You should generally prefer add_function instead of this.

parameter_count should reflect the parameter count of the function. Pass None if the function accepts a variable number of arguments. Note that unlike with bare raw functions there can be two functions with the same name defined on a type, as long as they have different arities. Functions with specific arities take priority over varargs.

Note that this function consumes the builder; this is because calls to functions that add into the type are meant to be chained together in one expression.

Adds a raw static function to the type.

You should generally prefer add_static instead of this.

parameter_count should reflect the parameter count of the function. Pass None if the function accepts a variable number of arguments. Note that unlike with bare raw functions there can be two functions with the same name defined on a type, as long as they have different arities. Functions with specific arities take priority over varargs.

Note that this function consumes the builder; this is because calls to functions that add into the type are meant to be chained together in one expression.

Adds a raw constructor to the type.

You should generally prefer add_constructor instead of this.

parameter_count should reflect the parameter count of the function. Pass None if the function accepts a variable number of arguments. Note that unlike with bare raw functions there can be two functions with the same name defined on a type, as long as they have different arities. Functions with specific arities take priority over varargs.

Note that this function consumes the builder; this is because calls to functions that add into the type are meant to be chained together in one expression.

Adds an instance function to the struct.

The function must follow the “method” calling convention, in that it accepts &T or &mut T as its first parameter.

Adds a function that’s part of a built-in trait implementation.

The function must have a signature that’s compatible with the built-in trait in question.

Adds a static function to the struct.

The function must follow the “bare” calling convention, in that it doesn’t accept a reference to T as its first parameter.

Adds a constructor to the type.

A constructor is a static function responsible for creating instances of a type. The function passed to this one must return another function that actually constructs the object.

Constructors use the “bare” calling convention, in that they don’t accept a self parameter.

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.