Enum artichoke_backend::def::EnclosingRubyScope[][src]

pub enum EnclosingRubyScope {
    Class(ClassScope),
    Module(ModuleScope),
}
Expand description

Typesafe wrapper for the RClass * of the enclosing scope for an mruby Module or Class.

In Ruby, classes and modules can be defined inside of another class or module. mruby only supports resolving RClass pointers relative to an enclosing scope. This can be the top level with mrb_class_get and mrb_module_get or it can be under another class with mrb_class_get_under or module with mrb_module_get_under.

Because there is no C API to resolve class and module names directly, each class-like holds a reference to its enclosing scope so it can recursively resolve its enclosing RClass *.

Variants

Class(ClassScope)

Reference to a Ruby Class enclosing scope.

Module(ModuleScope)

Reference to a Ruby Module enclosing scope.

Implementations

Factory for EnclosingRubyScope::Class that clones a class::Spec.

This function is useful when extracting an enclosing scope from the class registry.

Factory for EnclosingRubyScope::Module that clones a module::Spec.

This function is useful when extracting an enclosing scope from the module registry.

Resolve the RClass * of the wrapped class or module.

Return None if the class-like has no EnclosingRubyScope.

The current implemention results in recursive calls to this function for each enclosing scope.

Safety

This function must be called within an Artichoke::with_ffi_boundary closure because the FFI APIs called in this function may require access to the Artichoke `State.

Get the fully qualified name of the wrapped class or module.

For example, in the following Ruby code, C has an fqname of A::B::C.

module A
  class B
    module C
      CONST = 1
    end
  end
end

The current implemention results in recursive calls to this function for each enclosing scope.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.