fn main() {

      let x : u8 = f::<u8>('a',10,100);
      println!("{}",x);
      let x  = f('a',100,1000);
      println!("{}",x);
      let x = f('z',37. as f32,99.);
      println!("{}",x);
   
   fn f<T>(ch : char,num1 : T,num2 : T) -> T{
       if ch == 'a'{
           num1
       } else {
           num2
       }
   }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: