Advertisement
cwchen

[Rust] Rational class

Sep 4th, 2017
3,277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.28 KB | None | 0 0
  1. // Trait for binary '+' operator
  2. use std::ops::Add;
  3.  
  4. // Trait for formatted string
  5. use std::fmt;
  6.  
  7. // Automatically implement Copy and Clone trait
  8. // Therefore, our class acts as a primitive type
  9. #[derive(Copy, Clone)]
  10. pub struct Rational {
  11.     num: i32,
  12.     denom: i32,
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement