Macro abi_stable::tl_genparams
source · macro_rules! tl_genparams { ( $($lt:lifetime),* $(,)? ; $($ty:expr)? ; $($const_p:expr)? ) => { ... }; }
Expand description
Can be used to construct CompGenericParams
,
when manually implementing StableAbi
.
This stores indices and ranges for the type and/or const parameters 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 a range of indices into a slice:
-
: No elements.
-i
: Uses the i
th element.
-i..j
: Uses the elements from i up to j (exclusive).
-i..=j
: Uses the elements from i up to j (inclusive).
-x: StartLen
: Uses the elements from x.start()
up to x.end()
(exclusive).
For type parameters, this conceptually references the elements from
the slice returned by SharedVars::type_layouts
.
For const parameters, this conceptually references the elements from
the slice returned by SharedVars::constants
.
§Example
use abi_stable::{
type_layout::CompGenericParams,
tl_genparams,
};
const NO_ARGUMENTS: CompGenericParams = tl_genparams!(;;);
const THREE_TYPE_ARGUMENTS: CompGenericParams = tl_genparams!(; 0..=2;);
const ALL_ARGUMENTS: CompGenericParams = tl_genparams!('a,'b,'c,'d; 0; 0..3);