Function arbitrary::size_hint::recursion_guard
source · [−]pub fn recursion_guard(
depth: usize,
f: impl FnOnce(usize) -> (usize, Option<usize>)
) -> (usize, Option<usize>)
Expand description
Protects against potential infinite recursion when calculating size hints due to indirect type recursion.
When the depth is not too deep, calls f
with depth + 1
to calculate the
size hint.
Otherwise, returns the default size hint: (0, None)
.