Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate num;
- use std::ops::AddAssign;
- use num::Integer;
- fn add_1<T: Integer + AddAssign<i32> + PartialEq<i32>>(v: &mut T) {
- if *v == 0 {
- *v += 1
- }
- }
- fn main() {
- let mut x = 0;
- println!("{}", x);
- add_1(&mut x);
- println!("{}", x);
- }
Add Comment
Please, Sign In to add comment