Skip to main content

RObject

Struct RObject 

Source
pub struct RObject {
    pub tt: RType,
    pub value: RValue,
    pub object_id: Cell<u64>,
    pub singleton_class: RefCell<Option<Rc<RClass>>>,
    pub ivar: RefCell<RHashMap<String, Rc<RObject>>>,
}
Expand description

Heap-allocated Ruby object wrapper containing type tag, value, and object id.

Fields§

§tt: RType§value: RValue§object_id: Cell<u64>§singleton_class: RefCell<Option<Rc<RClass>>>§ivar: RefCell<RHashMap<String, Rc<RObject>>>

Implementations§

Source§

impl RObject

Source

pub fn nil() -> Self

Source

pub fn boolean(b: bool) -> Self

Source

pub fn symbol(sym: RSym) -> Self

Source

pub fn integer(n: i64) -> Self

Source

pub fn float(f: f64) -> Self

Source

pub fn string(s: String) -> Self

Source

pub fn string_from_vec(v: Vec<u8>) -> Self

Source

pub fn array(v: Vec<Rc<RObject>>) -> Self

Source

pub fn hash(h: RHash) -> Self

Source

pub fn range(start: Rc<RObject>, end: Rc<RObject>, exclusive: bool) -> Self

Source

pub fn class(c: Rc<RClass>, vm: &mut VM) -> Rc<Self>

Source

pub fn class_singleton(c: Rc<RClass>, vm: &mut VM) -> Rc<RClass>

Source

pub fn module(m: Rc<RModule>) -> Self

Source

pub fn class_or_module(c: Rc<RModule>, vm: &mut VM) -> Rc<Self>

Source

pub fn instance(c: Rc<RClass>) -> Self

Source

pub fn proc(p: RProc) -> Self

Source

pub fn exception(e: Rc<RException>) -> Self

Source

pub fn to_refcount_assigned(self) -> Rc<Self>

Source

pub fn is_falsy(&self) -> bool

Source

pub fn is_truthy(&self) -> bool

Source

pub fn is_nil(&self) -> bool

Source

pub fn is_main(&self) -> bool

Source

pub fn set_ivar(&self, key: &str, value: Rc<RObject>)

Source

pub fn get_ivar(&self, key: &str) -> Rc<RObject>

Source

pub fn as_hash_key(&self) -> Result<ValueHasher, Error>

Source

pub fn as_eq_value(&self) -> ValueEquality

Source

pub fn get_class(&self, vm: &VM) -> Rc<RClass>

Source

pub fn singleton_or_this_class(self: &Rc<Self>, vm: &mut VM) -> Rc<RClass>

Source

pub fn intern(&self) -> Result<RSym, Error>

Source

pub fn as_vec_owned(&self) -> Result<Vec<Rc<RObject>>, Error>

Trait Implementations§

Source§

impl Clone for RObject

Source§

fn clone(&self) -> RObject

Returns a duplicate 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 RObject

Source§

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

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

impl From<Rc<RModule>> for RObject

Source§

fn from(value: Rc<RModule>) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for RObject

Source§

fn eq(&self, other: &Self) -> 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 TryFrom<&RObject> for ()

Source§

type Error = Error

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

fn try_from(_: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for (i32, i32)

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for (i32, i32, i32)

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for (i32, i32, i32, i32)

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for *mut u8

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for String

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for Vec<(Rc<RObject>, Rc<RObject>)>

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for Vec<Rc<RObject>>

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for Vec<u8>

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for bool

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for f32

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for f64

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for i32

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for i64

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for u32

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for u64

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&RObject> for usize

Source§

type Error = Error

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

fn try_from(value: &RObject) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl !Freeze for RObject

§

impl !RefUnwindSafe for RObject

§

impl !Send for RObject

§

impl !Sync for RObject

§

impl Unpin for RObject

§

impl !UnwindSafe for RObject

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