Struct starlark::environment::MethodsBuilder
source · [−]pub struct MethodsBuilder { /* private fields */ }
Expand description
Used to build a Methods
value.
Implementations
sourceimpl MethodsBuilder
impl MethodsBuilder
sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty MethodsBuilder
, with no functions in scope.
sourcepub fn with(self, f: impl FnOnce(&mut Self)) -> Self
pub fn with(self, f: impl FnOnce(&mut Self)) -> Self
A fluent API for modifying MethodsBuilder
and returning the result.
sourcepub fn set_docstring(&mut self, docstring: &str)
pub fn set_docstring(&mut self, docstring: &str)
Set the raw docstring for this object.
sourcepub fn set_attribute<'v, V: AllocFrozenValue>(
&'v mut self,
name: &str,
value: V,
docstring: Option<String>
)
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
.
sourcepub fn set_attribute_fn<F>(
&mut self,
name: &str,
speculative_exec_safe: bool,
docstring: Option<String>,
typ: String,
f: F
) where
F: for<'v> Fn(Value<'v>, &'v Heap) -> Result<Value<'v>> + Send + Sync + 'static,
pub fn set_attribute_fn<F>(
&mut self,
name: &str,
speculative_exec_safe: bool,
docstring: Option<String>,
typ: String,
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.
sourcepub fn set_method<F>(
&mut self,
name: &str,
speculative_exec_safe: bool,
raw_docs: NativeCallableRawDocs,
typ: Option<FrozenValue>,
f: F
) where
F: for<'v> Fn(&mut Evaluator<'v, '_>, Value<'v>, &Arguments<'v, '_>) -> Result<Value<'v>> + Send + Sync + 'static,
pub fn set_method<F>(
&mut self,
name: &str,
speculative_exec_safe: bool,
raw_docs: NativeCallableRawDocs,
typ: Option<FrozenValue>,
f: F
) where
F: for<'v> Fn(&mut Evaluator<'v, '_>, Value<'v>, &Arguments<'v, '_>) -> Result<Value<'v>> + Send + Sync + 'static,
Set a method. This function is usually called from code
generated by starlark_derive
and rarely needs to be called manually.
sourcepub fn alloc<'v, V: AllocFrozenValue>(&'v self, value: V) -> FrozenValue
pub fn alloc<'v, V: AllocFrozenValue>(&'v self, value: V) -> FrozenValue
Allocate a value using the same underlying heap as the MethodsBuilder
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for MethodsBuilder
impl Send for MethodsBuilder
impl !Sync for MethodsBuilder
impl Unpin for MethodsBuilder
impl !UnwindSafe for MethodsBuilder
Blanket Implementations
sourceimpl<T> AsARef<T> for T where
T: ?Sized,
impl<T> AsARef<T> for T where
T: ?Sized,
sourcefn try_as_aref(this: &T) -> Result<ARef<'_, T>, BorrowError>
fn try_as_aref(this: &T) -> Result<ARef<'_, T>, BorrowError>
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more