sim_random_range_or_default

Function sim_random_range_or_default 

Source
pub fn sim_random_range_or_default<T>(range: Range<T>) -> T
Expand description

Generate a random value within the given range, returning the start value if the range is empty.

This is a safe version of sim_random_range that handles empty ranges gracefully by returning the start value when start == end.

§Parameters

  • range - The range to sample from (start..end)

§Returns

A random value within the range, or the start value if the range is empty.

Generate a random value in range or return start value if range is empty.