macro_rules! project {
(&($c:expr).$($f:tt).*) => {{
let c = $c;
unsafe { $crate::project(c, |inner| ::core::ptr::addr_of!((*inner).$($f).*)) }
}};
}
This successfully matches field accesses like:
project!(&(a).b.c);
project!(&(get_a()).b.c);
However, it doesn't work for index operations, which I was hoping the $f:tt would match:
project!(&(a).b.[0]);
project!(&(a).b.[1..2]);
Is there any way to get this to match both normal field accesses and indexing operations? Better yet, is there a way to do that without using the leading period (.[0]) syntax?