pub struct BoxValue<T>(_);
Expand description
Protects a Ruby Value from the garbage collector.
See also Value::leak
for a value that should be permanently excluded
from garbage collection.
All Value
methods should be available on this type through Deref
,
but some may be missed by this documentation.
Implementations
sourceimpl<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
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more