pub fn select<T>(condition: bool, true_val: T, false_val: T) -> TExpand description
Selects one of two values based on a condition.
This is a convenience function for conditional value selection, similar to the ternary operator in other languages.
§Type Parameters
T- The type of values to select from.
§Arguments
condition- Iftrue, returnstrue_val; otherwise returnsfalse_val.true_val- The value to return if condition istrue.false_val- The value to return if condition isfalse.
§Returns
true_val if condition is true, otherwise false_val.
§Example
use matrix_gui::prelude::*;
let value = matrix_utils::select(true, 10, 20); // Returns 10
let value2 = matrix_utils::select(false, 10, 20); // Returns 20