I had a code in Rust. I wanted to code this in Rescript.
Does Rescript support impl ? or anything similar to this ?
trait Trait1 {
fn method1(&self);
}
trait Trait2 {
fn method2(&self);
}
struct MyStruct;
impl Trait1 for MyStruct {
fn method1(&self) {
println!("Method 1 called");
}
}
impl Trait2 for MyStruct {
fn method2(&self) {
println!("Method 2 called");
}
}
fn call_methods<T>(item: &T)
where
T: Trait1 + Trait2,
{
item.method1();
item.method2();
}
fn main() {
let my_struct = MyStruct;
call_methods(&my_struct);
}