pub struct MethodsBuilder { /* private fields */ }
Expand description

Used to build a Methods value.

Implementations§

source§

impl MethodsBuilder

source

pub fn new() -> Self

Create an empty MethodsBuilder, with no functions in scope.

source

pub fn build(self) -> Methods

Called at the end to build a Methods.

source

pub fn with(self, f: impl FnOnce(&mut Self)) -> Self

A fluent API for modifying MethodsBuilder and returning the result.

source

pub fn set_docstring(&mut self, docstring: &str)

Set the raw docstring for this object.

source

pub fn set_attribute<'v, V: AllocFrozenValue>( &'v mut self, name: &str, value: V, docstring: Option<String> )

Set a constant value in the MethodsBuilder that will be suitable for use with StarlarkValue::get_methods.

source

pub fn set_attribute_fn<F>( &mut self, name: &str, speculative_exec_safe: bool, docstring: Option<String>, typ: Ty, f: F )
where F: for<'v> Fn(Value<'v>, &'v Heap) -> Result<Value<'v>> + Send + Sync + 'static,

Set an attribute. This function is usually called from code generated by starlark_derive and rarely needs to be called manually.

source

pub fn set_method<F>( &mut self, name: &str, speculative_exec_safe: bool, raw_docs: NativeCallableRawDocs, f: F )
where F: NativeMeth,

Set a method. This function is usually called from code generated by starlark_derive and rarely needs to be called manually.

source

pub fn alloc<'v, V: AllocFrozenValue>(&'v self, value: V) -> FrozenValue

Allocate a value using the same underlying heap as the MethodsBuilder

Trait Implementations§

source§

impl Debug for MethodsBuilder

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> ToAst for T

source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

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.