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

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

Converts this type into a mutable reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.