pub struct DataObjectRef(/* private fields */);Implementations§
Source§impl DataObjectRef
impl DataObjectRef
pub fn new(data_object: DataObject) -> Self
pub fn text_value(&self) -> Option<Box<str>>
pub fn byte_buffer_value(&self) -> Option<Rc<RefCell<Box<[u8]>>>>
pub fn array_value(&self) -> Option<Rc<RefCell<Box<[DataObjectRef]>>>>
pub fn list_value(&self) -> Option<Rc<RefCell<VecDeque<DataObjectRef>>>>
pub fn var_pointer_value(&self) -> Option<DataObjectRef>
pub fn function_pointer_value(&self) -> Option<FunctionPointerObjectRef>
pub fn struct_value(&self) -> Option<Rc<StructObject>>
pub fn object_value(&self) -> Option<LangObjectRef>
pub fn int_value(&self) -> Option<i32>
pub fn long_value(&self) -> Option<i64>
pub fn float_value(&self) -> Option<f32>
pub fn double_value(&self) -> Option<f64>
pub fn char_value(&self) -> Option<char>
pub fn error_value(&self) -> Option<Rc<ErrorObject>>
pub fn type_value(&self) -> Option<DataType>
Sourcepub fn number_value(&self) -> Option<Number>
pub fn number_value(&self) -> Option<Number>
This method borrows the data object and copies the value from DataObject::number_value
Sourcepub fn bool_value(&self) -> Option<bool>
pub fn bool_value(&self) -> Option<bool>
This method borrows the data object and copies the value from DataObject::bool_value
pub fn variable_name(&self) -> Option<Box<str>>
pub fn is_final_data(&self) -> bool
pub fn is_static_data(&self) -> bool
pub fn is_copy_static_and_final_modifiers(&self) -> bool
pub fn is_lang_var(&self) -> bool
pub fn data_type(&self) -> DataType
Sourcepub fn type_constraint(&self) -> DataTypeConstraint
pub fn type_constraint(&self) -> DataTypeConstraint
This functions clones data
pub fn member_visibility(&self) -> Option<Visibility>
pub fn member_of_class(&self) -> i64
pub fn is_accessible(&self, accessing_class: Option<&LangObjectRef>) -> bool
Methods from Deref<Target = RefCell<DataObject>>§
1.24.0 · Sourcepub fn replace(&self, t: T) -> T
pub fn replace(&self, t: T) -> T
Replaces the wrapped value with a new one, returning the old value, without deinitializing either one.
This function corresponds to std::mem::replace.
§Panics
Panics if the value is currently borrowed.
§Examples
use std::cell::RefCell;
let cell = RefCell::new(5);
let old_value = cell.replace(6);
assert_eq!(old_value, 5);
assert_eq!(cell, RefCell::new(6));1.35.0 · Sourcepub fn replace_with<F>(&self, f: F) -> T
pub fn replace_with<F>(&self, f: F) -> T
Replaces the wrapped value with a new one computed from f, returning
the old value, without deinitializing either one.
§Panics
Panics if the value is currently borrowed.
§Examples
use std::cell::RefCell;
let cell = RefCell::new(5);
let old_value = cell.replace_with(|&mut old| old + 1);
assert_eq!(old_value, 5);
assert_eq!(cell, RefCell::new(6));1.24.0 · Sourcepub fn swap(&self, other: &RefCell<T>)
pub fn swap(&self, other: &RefCell<T>)
Swaps the wrapped value of self with the wrapped value of other,
without deinitializing either one.
This function corresponds to std::mem::swap.
§Panics
Panics if the value in either RefCell is currently borrowed, or
if self and other point to the same RefCell.
§Examples
use std::cell::RefCell;
let c = RefCell::new(5);
let d = RefCell::new(6);
c.swap(&d);
assert_eq!(c, RefCell::new(6));
assert_eq!(d, RefCell::new(5));1.0.0 · Sourcepub fn borrow(&self) -> Ref<'_, T>
pub fn borrow(&self) -> Ref<'_, T>
Immutably borrows the wrapped value.
The borrow lasts until the returned Ref exits scope. Multiple
immutable borrows can be taken out at the same time.
§Panics
Panics if the value is currently mutably borrowed. For a non-panicking variant, use
try_borrow.
§Examples
use std::cell::RefCell;
let c = RefCell::new(5);
let borrowed_five = c.borrow();
let borrowed_five2 = c.borrow();An example of panic:
use std::cell::RefCell;
let c = RefCell::new(5);
let m = c.borrow_mut();
let b = c.borrow(); // this causes a panic1.13.0 · Sourcepub fn try_borrow(&self) -> Result<Ref<'_, T>, BorrowError>
pub fn try_borrow(&self) -> Result<Ref<'_, T>, BorrowError>
Immutably borrows the wrapped value, returning an error if the value is currently mutably borrowed.
The borrow lasts until the returned Ref exits scope. Multiple immutable borrows can be
taken out at the same time.
This is the non-panicking variant of borrow.
§Examples
use std::cell::RefCell;
let c = RefCell::new(5);
{
let m = c.borrow_mut();
assert!(c.try_borrow().is_err());
}
{
let m = c.borrow();
assert!(c.try_borrow().is_ok());
}1.0.0 · Sourcepub fn borrow_mut(&self) -> RefMut<'_, T>
pub fn borrow_mut(&self) -> RefMut<'_, T>
Mutably borrows the wrapped value.
The borrow lasts until the returned RefMut or all RefMuts derived
from it exit scope. The value cannot be borrowed while this borrow is
active.
§Panics
Panics if the value is currently borrowed. For a non-panicking variant, use
try_borrow_mut.
§Examples
use std::cell::RefCell;
let c = RefCell::new("hello".to_owned());
*c.borrow_mut() = "bonjour".to_owned();
assert_eq!(&*c.borrow(), "bonjour");An example of panic:
use std::cell::RefCell;
let c = RefCell::new(5);
let m = c.borrow();
let b = c.borrow_mut(); // this causes a panic1.13.0 · Sourcepub fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, BorrowMutError>
pub fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, BorrowMutError>
Mutably borrows the wrapped value, returning an error if the value is currently borrowed.
The borrow lasts until the returned RefMut or all RefMuts derived
from it exit scope. The value cannot be borrowed while this borrow is
active.
This is the non-panicking variant of borrow_mut.
§Examples
use std::cell::RefCell;
let c = RefCell::new(5);
{
let m = c.borrow();
assert!(c.try_borrow_mut().is_err());
}
assert!(c.try_borrow_mut().is_ok());1.12.0 · Sourcepub fn as_ptr(&self) -> *mut T
pub fn as_ptr(&self) -> *mut T
Returns a raw pointer to the underlying data in this cell.
§Examples
use std::cell::RefCell;
let c = RefCell::new(5);
let ptr = c.as_ptr();1.37.0 · Sourcepub unsafe fn try_borrow_unguarded(&self) -> Result<&T, BorrowError>
pub unsafe fn try_borrow_unguarded(&self) -> Result<&T, BorrowError>
Immutably borrows the wrapped value, returning an error if the value is currently mutably borrowed.
§Safety
Unlike RefCell::borrow, this method is unsafe because it does not
return a Ref, thus leaving the borrow flag untouched. Mutably
borrowing the RefCell while the reference returned by this method
is alive is undefined behavior.
§Examples
use std::cell::RefCell;
let c = RefCell::new(5);
{
let m = c.borrow_mut();
assert!(unsafe { c.try_borrow_unguarded() }.is_err());
}
{
let m = c.borrow();
assert!(unsafe { c.try_borrow_unguarded() }.is_ok());
}Trait Implementations§
Source§impl AnyWithEq for DataObjectRef
impl AnyWithEq for DataObjectRef
fn as_any(&self) -> &dyn Any
fn is_equals( &self, other: &dyn AnyWithEq, interpreter: &mut Interpreter, pos: CodePosition, ) -> bool
fn is_strict_equals( &self, other: &dyn AnyWithEq, interpreter: &mut Interpreter, pos: CodePosition, ) -> bool
Source§impl Clone for DataObjectRef
impl Clone for DataObjectRef
Source§fn clone(&self) -> DataObjectRef
fn clone(&self) -> DataObjectRef
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more