Macro partial_ref::partial

source ·
macro_rules! partial {
    ($target:ty) => { ... };
    ($target_lt:lifetime $target:ty) => { ... };
    ($target:ty, $($parts:tt)* ) => { ... };
    ($target_lt:lifetime $target:ty, $($parts:tt)*) => { ... };
    (@extend $target:ty) => { ... };
    (@extend $target:ty, ) => { ... };
    (@extend $target:ty, mut $($part:ty)|* , $($rest:tt)*) => { ... };
    (@extend $target:ty, mut $($part:ty)|*) => { ... };
    (@extend $target:ty, $($part:ty)|* , $($rest:tt)*) => { ... };
    (@extend $target:ty, $($part:ty)|*) => { ... };
}
Expand description

Concise syntax for partial reference types.

The first parameter is the reference target type, optionally preceded by a lifetime. The following parameters are the referenced parts, each optionally preceded by the keyword mut to indicate a mutable reference to that part. Nested parts can be specified using the pipe syntax of nested_part.

Examples:

  • partial!(Ty, PartA) is Const<PartA, Ref<Ty>>
  • partial!('a Ty, mut PartA) is Mut<PartA, Ref<'a, Ty>>
  • partial!(Ty, PartA, PartB, mut PartC) is Const<PartA, Const<PartB, Mut<PartC, Ref<Ty>>
  • partial!('a Ty, mut PartA | PartB) is Mut<Nested<PartA, PartB>, Ref<'a, Ty>>