pub struct BoxValue<T>(/* private fields */);
Expand description
Protects a Ruby Value from the garbage collector.
See also gc::register_mark_object
for
a value that should be permanently excluded from garbage collection.
Implementations§
source§impl<T> BoxValue<T>where
T: ReprValue,
impl<T> BoxValue<T>where
T: ReprValue,
sourcepub fn new(val: T) -> Self
pub fn new(val: T) -> Self
Create a new BoxValue
.
§Examples
use magnus::{eval, gc, value::BoxValue, RString, Value};
fn box_value() -> BoxValue<RString> {
BoxValue::new(RString::new("foo"))
}
let boxed = box_value();
// run garbage collector
gc::start();
// boxed is still useable
let result: String = eval!(r#"foo + "bar""#, foo = boxed).unwrap();
assert_eq!(result, "foobar");
Trait Implementations§
impl<T> IntoValueFromNative for BoxValue<T>where
T: ReprValue,
Auto Trait Implementations§
impl<T> Freeze for BoxValue<T>
impl<T> RefUnwindSafe for BoxValue<T>where
T: RefUnwindSafe,
impl<T> Send for BoxValue<T>where
T: Send,
impl<T> Sync for BoxValue<T>where
T: Sync,
impl<T> Unpin for BoxValue<T>
impl<T> UnwindSafe for BoxValue<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more