Best way to implementation generic function get numbers

i want write function get number Including i32,u32,i64,u64,f32,… and return it what is best solution ?

Where are you getting the number from? More context please.

2 Likes

like this

fn dummy_func<T: Number>(t: T) -> T {
// do somthing like sub, add, mod …
}

See ::num_traits

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.