Struct starlark::environment::GlobalsStatic [−][src]
pub struct GlobalsStatic(_);
Expand description
Used to create methods for a StarlarkValue
.
To define a method foo()
on your type, define
usually written as:
ⓘ
fn my_methods(builder: &mut GlobalsBuilder) {
fn foo(me: ARef<Foo>) -> NoneType {
...
}
}
impl StarlarkValue<'_> for Foo {
...
fn get_methods(&self) -> Option<&'static Globals> {
static RES: GlobalsStatic = GlobalsStatic::new();
RES.methods(module_creator)
}
...
}
Implementations
Create a new GlobalsStatic
.
Populate the globals with a builder function. Always returns Some
, but using this API
to be a better fit for StarlarkValue.get_methods
.
Get a function out of the object. Requires that the function passed only set a single
value. If populated via a #[starlark_module]
, that means a single function in it.
Move all the globals in this GlobalsBuilder
into a new one. All variables will
only be allocated once (ensuring things like function comparison works properly).