[][src]Function arbitrary::size_hint::recursion_guard

pub fn recursion_guard(
    depth: usize,
    f: impl FnOnce(usize) -> (usize, Option<usize>)
) -> (usize, Option<usize>)

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

See the docs for Arbitrary::shrink for example usage.