28 lines
563 B
Plaintext
28 lines
563 B
Plaintext
fn main(): i64 {
|
|
let user = User{id: 4};
|
|
let result = user.instance_method() + User::instance_method(user);
|
|
return result;
|
|
}
|
|
|
|
type User struct {
|
|
id: i64
|
|
}
|
|
|
|
type TestTrait trait {
|
|
fn class_method(id: i64): Self;
|
|
fn instance_method(self: Self): i64;
|
|
fn default_impl(self: Self): i64;
|
|
}
|
|
|
|
impl TestTrait for User {
|
|
fn class_method(id: i64): Self {
|
|
return Self{id: id};
|
|
}
|
|
fn instance_method(self: Self): i64 {
|
|
return self.id;
|
|
}
|
|
fn default_impl(self: Self): i64 {
|
|
return self.instance_method();
|
|
}
|
|
}
|