Struct Value

Source
pub struct Value(pub VALUE);
Expand description

A Ruby value.

Tuple Fields§

§0: VALUE

Implementations§

Source§

impl Value

Source

pub fn nil() -> Value

Gets nil.

Source

pub fn boolean(b: bool) -> Value

Gets a boolean value.

Source

pub fn boolean_true() -> Value

Gets the boolean true value.

Source

pub fn boolean_false() -> Value

Gets the boolean false value.

Source

pub fn symbol<S>(name: S) -> Value
where S: AsRef<str>,

Creates a new symbol.

Source

pub fn string<S>(s: S) -> Value
where S: AsRef<str>,

Creates a new String.

Source

pub fn integer<I>(v: I) -> Value
where I: Into<i64>,

Creates a new Integer.

Source

pub fn float<F>(v: F) -> Value
where F: Into<f64>,

Creates a new Float.

Source

pub fn to_sym(&self) -> Value

Converts the value into a symbol.

Source

pub fn to_i64(&self) -> i64

Converts the value to a 64-bit signed integer.

Source

pub fn to_u64(&self) -> u64

Converts the value to a 64-bit unsigned integer.

Source

pub fn to_f64(&self) -> f64

Converts the value into a 64-bit float.

Source

pub fn class(&self) -> Value

Gets the class.

Source

pub fn nested_class<S>(self, name: S) -> Class
where S: Into<String>,

Creates a nested class.

Source

pub fn nested_module<S>(self, name: S) -> Module
where S: Into<String>,

Creates a nested module.

Source

pub fn display_string(&self) -> String

The value of Object#to_s.

Source

pub fn inspect_string(&self) -> String

The value of Object#inspect.

Source

pub fn class_name(&self) -> String

Gets the name of the class of the object.

Source

pub fn is_nil(&self) -> bool

Checks if the value is nil.

Source

pub fn is_true(&self) -> bool

Checks if the value is true.

Source

pub fn is_false(&self) -> bool

Checks if the value is false.

Source

pub fn is_string(&self) -> bool

Checks if the value is a String type.

Source

pub fn is_regex(&self) -> bool

Checks if the value is a regex.

Source

pub fn is_integer(&self) -> bool

Checks if the value is an Integer type.

Source

pub fn is_complex_number(&self) -> bool

Checks if the value is a complex number.

Source

pub fn is_rational(&self) -> bool

Checks if the value is a rational number.

Source

pub fn is_symbol(&self) -> bool

Checks if the value is a symbol.

Source

pub fn is_float(&self) -> bool

Checks if the value is a float.

Source

pub fn is_array(&self) -> bool

Checks if the value is an array.

Source

pub fn is_hash(&self) -> bool

Checks if the value is a hash.

Source

pub fn is_object(&self) -> bool

Checks if the value is an object.

Source

pub fn is_class(&self) -> bool

Checks if the value is a class.

Source

pub fn is_struct(&self) -> bool

Checks if the value is a Struct.

Source

pub fn is_module(&self) -> bool

Checks if the value is a module.

Source

pub fn is_equal_to(&self, other: Value) -> Value

Ruby’s version of ‘==’

Source

pub fn as_string(&self) -> Option<String>

Converts a Ruby String into a Rust String. Returns None if the value is not a Ruby String.

Source

pub fn call_no_args(&self, method_name: &str) -> Value

Calls a method with no args.

Source

pub fn send(&self, method_name: &str, args: &[Value]) -> Value

Sends a message to the value.

Source

pub fn get_ivar(&self, name: &str) -> Value

Gets the value of an instance variable by name. Returns nil if it doesn’t exist.

Source

pub fn set_ivar(&self, name: &str, value: Value) -> Value

Sets the value of an instance variable (or creates a new one).

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Value

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<VALUE> for Value

Source§

fn from(value: VALUE) -> Value

Converts to this type from the input type.
Source§

impl PartialEq for Value

Source§

fn eq(&self, rhs: &Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Value

Source§

impl Eq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.