[][src]Macro abi_stable::tl_genparams

macro_rules! tl_genparams {
    (count;  ) => { ... };
    (count; $v0:lifetime) => { ... };
    (count; $v0:lifetime,$v1:lifetime $(,$rem:lifetime)*) => { ... };
    ( $($lt:lifetime),* $(,)? ; $($ty:expr)? ; $($const_p:expr)? ) => { ... };
}

Use this when constructing a abi_stable::type_layout::MonoTypeLayout when manually implementing StableAbi.

This stores indices and ranges for the type and/or const parameter taken from the SharedVars of the TypeLayout where this is stored.

Syntax

tl_genparams!( (<lifetime>),* ; <convertible_to_startlen>; <convertible_to_startlen> )

<convertible_to_startlen> is one of:

-``: No generic parameters of that kind.

-i: Takes the ith generic parameter from the SharedVars slice of type or the one of const parameters.

-i..j: Takes from i to j exclusive generic parameter from the SharedVars slice of type or the one of const parameters.

-i..=j: Takes from i to j inclusive generic parameter from the SharedVars slice of type or the one of const parameters.

-x:StartLen: Takes from x.start() to x.end() exclusive generic parameter from the SharedVars slice of type or the one of const parameters.

Examples

No generic parameters:

use abi_stable::{
    type_layout::CompGenericParams,
    tl_genparams,
};

const PARAMS:CompGenericParams=tl_genparams!(;;);

One lifetime,one type parameter,one const parameter

use abi_stable::{
    type_layout::CompGenericParams,
    tl_genparams,
};

const PARAMS:CompGenericParams=tl_genparams!('a;0;0);

One lifetime,two type parameters,no const parameters

use abi_stable::{
    type_layout::CompGenericParams,
    tl_genparams,
};

const PARAMS:CompGenericParams=tl_genparams!('a;0..=1;);

Four lifetimes,no type parameters,three const parameters

use abi_stable::{
    type_layout::CompGenericParams,
    tl_genparams,
};

const PARAMS:CompGenericParams=tl_genparams!('a,'b,'c,'d;;0..3);

No lifetimes,two type parameters,no const parameters

use abi_stable::{
    type_layout::{CompGenericParams,StartLen},
    tl_genparams,
};

const PARAMS:CompGenericParams=tl_genparams!(;StartLen::new(0,2););