Rust trait explained

Code examples

2
0

rust trait

pub trait Summary {
    fn summarize(&self) -> String;
}
0
0

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)
    }
}

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................