Advertisement
cwchen

[Rust] C-style struct (mutable).

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