Advertisement
cwchen

[Rust] The constructor of Point class

Aug 28th, 2017
3,619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.27 KB | None | 0 0
  1. impl Point {
  2.     // Constructor, which is just a regular method
  3.     pub fn new(x: f64, y: f64) -> Point {
  4.         let mut p = Point{ x: 0.0, y: 0.0 };
  5.  
  6.         // Set the fields of Point through setters
  7.         p.set_x(x);
  8.         p.set_y(y);
  9.  
  10.         p
  11.     }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement