Advertisement
cwchen

[Rust] C-style struct demo.

Aug 23rd, 2017
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.22 KB | None | 0 0
  1. // For abs function
  2. use std::f64;
  3.  
  4. struct Point {
  5.     x: f64,
  6.     y: f64,
  7. }
  8.  
  9. fn main() {
  10.     let p = Point{ x: 3.0, y: 4.0 };
  11.  
  12.     assert!(f64::abs(p.x - 3.0) < 1e-10);
  13.     assert!(f64::abs(p.y - 4.0) < 1e-10);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement