macro_rules! p {
(#parse_base(
$action:ident($($action_args:tt)*),
input(
// A deref of a potentially-complex place expression.
(*$($place:tt)*)
$($rest:tt)*
)
)) => { ... };
(#parse_base(
$action:ident($($action_args:tt)*),
input(
// A deref of a local, with no projections.
*$local:ident
)
)) => { ... };
(#parse_base(
$action:ident($($action_args:tt)*),
input(
// A postfix deref
$local:ident.*
$($rest:tt)*
)
)) => { ... };
(#parse_base(
$action:ident($($action_args:tt)*),
input(
// Not a deref so we remove the parens (to support `(x.a).b`).
($($place:tt)*)
$($rest:tt)*
)
)) => { ... };
(#parse_proj(
$action:ident($($action_args:tt)*),
$start:ident($($start_args:tt)*),
project($($fields:tt)*),
input(
. * // postfix deref
$($input:tt)*
)
)) => { ... };
(#parse_proj(
$action:ident($($action_args:tt)*),
$start:ident($($start_args:tt)*),
project($($fields:tt)*),
input(
.$field:ident
$($rest:tt)*
)
)) => { ... };
(#parse_proj(
$action:ident($($action_args:tt)*),
$start:ident($($start_args:tt)*),
project($($fields:tt)*),
input(
$(= $rvalue:expr)?
)
)) => { ... };
(#parse_assign(
read_or_write(),
$start:ident($($start_args:tt)*),
project($($proj_args:tt)*),
input(
= $rvalue:expr
)
)) => { ... };
(#parse_assign(
read_or_write(),
$start:ident($($start_args:tt)*),
project($($proj_args:tt)*),
input()
)) => { ... };
(#parse_assign(
$action:ident($($action_args:tt)*),
$start:ident($($start_args:tt)*),
project($($proj_args:tt)*),
input()
)) => { ... };
(#compose_projs()) => { ... };
(#compose_projs(.$field:ident $($rest:tt)*)) => { ... };
(#build_start(deref($ptr:ident))) => { ... };
(#build_start(deref($($place:tt)*))) => { ... };
(#build(
$action:ident($($action_args:tt)*),
ptr($ptr:expr),
project($($proj_args:tt)*),
)) => { ... };
(#do_action(
read(),
base($ptr:expr),
project($proj:expr),
)) => { ... };
(#do_action(
deref(),
base($ptr:expr),
project($proj:expr),
)) => { ... };
(#do_action(
write($rvalue:expr),
base($ptr:expr),
project($proj:expr),
)) => { ... };
(#do_action(
borrow($($ptr_ty:tt)*),
base($ptr:expr),
project($proj:expr),
)) => { ... };
(#$($rest:tt)*) => { ... };
(@_ $($place:tt)*) => { ... };
(@$ptr:ident<$($ty:ty),*> $($place:tt)*) => { ... };
(@$ptr:ident $($place:tt)*) => { ... };
($($place:tt)*) => { ... };
}Expand description
Macro that simulates the proposed new syntax. Derefs must be explicit and
the identifiers used for field projections must actually be values of some
Projection type, e.g. built with mk_field_proj.
Examples:
(*p).a
-> a.read(&raw const p)
(*p).a.b
-> a.compose(b).read(&raw const p)
(**p).a
-> a.read(NoopProj::default().deref(&raw const p))
(*(*p).ptr_a).b
-> b.read(ptr_a.deref(&raw const p))
(*p).a = foo()
-> a.write(&raw const p, foo())
@R *p
-> NoopProj::default().borrow::<_, R<_>>(&raw const p)
@R (*p).a
-> a.borrow::<_, R<_>>(&raw const p)
@R (**p).a
-> a.borrow::<_, R<_>>(NoopProj::default().deref(&raw const p))