Struct arithmetic_typing::TupleLen
source · pub struct TupleLen { /* private fields */ }
Expand description
Generic tuple length.
A tuple length consists of the two components: an unknown / variable length,
such as UnknownLen::Var
, and a non-negative increment.
These components can be obtained via Self::components()
.
Static lengths
Tuple lengths can be either static or dynamic. Dynamic lengths are lengths
that contain UnknownLen::Dynamic
.
Functions, TypeArithmetic
s, etc. can specify constraints on lengths being static.
For example, this is a part of Ops
;
dynamically sized slices such as [Num]
cannot be added / multiplied / etc.,
even if they are of the same type. This constraint is denoted as len! N, M, ...
in the function quantifier, e.g., for<len! N> (['T; N]) -> 'T
.
If the constraint fails, an error will be raised with the kind
set to ErrorKind::DynamicLen
.
Implementations§
source§impl TupleLen
impl TupleLen
sourcepub fn components(&self) -> (Option<UnknownLen>, usize)
pub fn components(&self) -> (Option<UnknownLen>, usize)
Returns components of this length.
sourcepub fn components_mut(&mut self) -> (Option<&mut UnknownLen>, &mut usize)
pub fn components_mut(&mut self) -> (Option<&mut UnknownLen>, &mut usize)
Returns mutable references to the components of this length.