reth_primitives::arbitrary::size_hint

Function try_recursion_guard

pub fn try_recursion_guard(
    depth: usize,
    f: impl FnOnce(usize) -> Result<(usize, Option<usize>), MaxRecursionReached>,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
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 an error.

This should be used when implementing try_size_hint