Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

trait in rust

struct Point(isize, isize);

trait IPoint {
	fn new(x: isize, y: isize) -> Point {
    	Point(x, y)
    }
	fn coord(&self) -> (isize, isize);
}

impl IPoint for Point {
	fn coord(&self) -> (isize, isize) {
    	(self.0, self.1)
    }
}
Source by doc.rust-lang.org #
 
PREVIOUS NEXT
Tagged: #trait #rust
ADD COMMENT
Topic
Name
9+2 =