Skip to content

Instantly share code, notes, and snippets.

@dlecan
Created July 11, 2016 21:21
Show Gist options
  • Save dlecan/9377cc795ecfef5f2d613b70d0c6c292 to your computer and use it in GitHub Desktop.
Save dlecan/9377cc795ecfef5f2d613b70d0c6c292 to your computer and use it in GitHub Desktop.
fn calculer_division(x: i32, y: i32) -> i32 {
match y {
0 => panic!("Division par 0"),
1 => x,
_ => x / y
}
}
fn main() {
let resultat = calculer_division(-4, 2);
println!("Résultat : {}", resultat);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment