summaryrefslogblamecommitdiff
path: root/meap/meap-code/ch2/ch2-generic-add.rs
blob: 8f1a8a9fe970855d6b409d6caf6a510e88710407 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16















                                              
use std::ops::{Add};

fn add<T: Add<Output = T>>(i: T, j: T) -> T {
  i + j
}

fn main() {
  let (a, b) = (1.2, 3.4);
  let (x, y) = (10, 20);

  let c = add(a,b);
  let z = add(x,y);

  println!("{} + {} = {}", a, b, c);
  println!("{} + {} = {}", x, y, z);
}