Macro owned_pin::arsc_on_stack
source · macro_rules! arsc_on_stack { (let $value:ident = $init:expr) => { ... }; }
Expand description
Creates an Arsc pointer on the current calling stack.
The syntax of this macro is different from the syntax of
on_stack, due to its own implementation and the
restriction on lifetime extensions of temporary values in Rust.
Examples
use owned_pin::sync::{Arsc, RefCount, RefCounted, arsc_on_stack};
use owned_pin::OnStack;
#[derive(RefCounted)]
struct A {
value: &'static str,
#[count_on]
rc: RefCount,
}
// `arsc` is `Arsc<OnStack<A>>`.
arsc_on_stack!(let arsc = A {
value: "Hello!",
rc: RefCount::new(),
});
// All the clones share the same lifetime.
let cloned = arsc.clone();
assert!(Arsc::ptr_eq(&arsc, &cloned));