macro_rules! coerce_gc {
($gc:expr) => { ... };
}Expand description
Allows coercing T of Gc<T>.
This means that you can convert a Gc containing a strictly-sized type (such as [T; N]) into
a Gc containing its unsized version (such as [T]), all without using nightly-only features.
This is one of two easy ways to create a Gc<[T]>; the other method is to use FromIterator.
§Examples
use dumpster::sync::{coerce_gc, Gc};
let gc1: Gc<[u8; 3]> = Gc::new([7, 8, 9]);
let gc2: Gc<[u8]> = coerce_gc!(gc1);
assert_eq!(&gc2[..], &[7, 8, 9]);Note that although this macro allows for type conversion, it cannot be used for converting between incompatible types.
ⓘ
// This program is incorrect!
use dumpster::sync::{Gc, coerce_gc};
let gc1: Gc<u8> = Gc::new(1);
let gc2: Gc<i8> = coerce_gc!(gc1);