Forward
#[derive(Forward)] generates methods that delegate to inner fields (structs) or variant payloads (enums). You declare the method signatures to forward using #[moxy(forward(fn ...))].
Since proc macros cannot see type information, you explicitly declare which methods to forward.
use moxy::Forward;
#[derive(Forward)]
struct Cache {
#[moxy(forward(
fn len(&self) -> usize,
fn is_empty(&self) -> bool,
))]
store: Vec<String>,
}
let cache = Cache { store: vec!["a".into(), "b".into()] };
assert_eq!(cache.len(), 2);
assert!(!cache.is_empty());