[][src]Trait artichoke::prelude::DefineConstant

pub trait DefineConstant {
    type Value: Value;
    type Error;
    pub fn define_global_constant(
        &mut self,
        constant: &str,
        value: Self::Value
    ) -> Result<(), Self::Error>;
pub fn define_class_constant<T>(
        &mut self,
        constant: &str,
        value: Self::Value
    ) -> Result<(), Self::Error>
    where
        T: 'static
;
pub fn define_module_constant<T>(
        &mut self,
        constant: &str,
        value: Self::Value
    ) -> Result<(), Self::Error>
    where
        T: 'static
; }

Deifne constants on an interprter.

Constants can be an arbitrary Ruby value. Constants can be defined globally, on a class, or on a module.

Associated Types

type Value: Value[src]

Concrete type for Ruby values.

type Error[src]

Concrete error type for fallible operations.

Loading content...

Required methods

pub fn define_global_constant(
    &mut self,
    constant: &str,
    value: Self::Value
) -> Result<(), Self::Error>
[src]

Define a global constant.

Errors

If the given constant name is not valid, an error is returned.

If the interpreter cannot define the constant, an error is returned.

pub fn define_class_constant<T>(
    &mut self,
    constant: &str,
    value: Self::Value
) -> Result<(), Self::Error> where
    T: 'static, 
[src]

Define a class constant.

The class is specified by the type parameter T.

Errors

If the class named by type T is not defined, an error is returned.

If the given constant name is not valid, an error is returned.

If the interpreter cannot define the constant, an error is returned.

pub fn define_module_constant<T>(
    &mut self,
    constant: &str,
    value: Self::Value
) -> Result<(), Self::Error> where
    T: 'static, 
[src]

Define a module constant.

The class is specified by the type parameter T.

Errors

If the module named by type T is not defined, an error is returned.

If the given constant name is not valid, an error is returned.

If the interpreter cannot define the constant, an error is returned.

Loading content...

Implementors

impl DefineConstant for Artichoke[src]

type Value = Value

type Error = Error

Loading content...