pub trait DefineConstant {
type Value: Value;
type Error;
// Required methods
fn define_global_constant(
&mut self,
constant: &str,
value: Self::Value,
) -> Result<(), Self::Error>;
fn define_class_constant<T>(
&mut self,
constant: &str,
value: Self::Value,
) -> Result<(), Self::Error>
where T: 'static;
fn define_module_constant<T>(
&mut self,
constant: &str,
value: Self::Value,
) -> Result<(), Self::Error>
where T: 'static;
}
Expand description
Define constants on an interpreter.
Constants can be an arbitrary Ruby value. Constants can be defined globally, on a class, or on a module.
Required Associated Types§
Required Methods§
Sourcefn define_global_constant(
&mut self,
constant: &str,
value: Self::Value,
) -> Result<(), Self::Error>
fn define_global_constant( &mut self, constant: &str, value: Self::Value, ) -> Result<(), Self::Error>
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.
Sourcefn define_class_constant<T>(
&mut self,
constant: &str,
value: Self::Value,
) -> Result<(), Self::Error>where
T: 'static,
fn define_class_constant<T>(
&mut self,
constant: &str,
value: Self::Value,
) -> Result<(), Self::Error>where
T: 'static,
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.
Sourcefn define_module_constant<T>(
&mut self,
constant: &str,
value: Self::Value,
) -> Result<(), Self::Error>where
T: 'static,
fn define_module_constant<T>(
&mut self,
constant: &str,
value: Self::Value,
) -> Result<(), Self::Error>where
T: 'static,
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.