Macro abi_stable::tl_genparams[][src]

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

Use this when constructing a MonoTypeLayout when manually implementing StableAbi.

This stores indices and ranges for the type and/or const parameter taken from the SharedVars stored in the same 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 type or const parameter(indexed separately).

-i..j: Takes from i to j (exclusive) type or const parameter(indexed separately).

-i..=j: Takes from i to j (inclusive) type or const parameter(indexed separately).

-x:StartLen: Takes from x.start() to x.end() (exclusive) type or const parameter(indexed separately).

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););