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).

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Get an ARef pointing at this type.

Try and get an ARef pointing at this type. Returns an Err if the type Self is a RefCell which is already mutably borrowed. Read more

Return the underlying RefCell if Self is one, otherwise None.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Convert between two equal types.

Convert between references to two equal types.

Convert between mutable references to two equal types.

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.