/******************************************************************************
Online Rust Compiler.
Code, Compile, Run and Debug Rust program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
use std::ops::Add;
struct Cat {
name: String,
}
struct Dog {
name: String,
}
impl Dog {
fn callyourself(&self) -> String {
let me = self.name.to_string();
me
}
}
impl Cat {
fn callyourself(&self) -> String {
let me = self.name.to_string();
me
}
}
impl Add<Dog> for Cat {
type Output = String;
fn add(self, other: Dog) -> String {
format!("{}о{}", self.callyourself(), other.callyourself())
}
}
fn main() {
let dog = Dog { name: "пёс".to_string() };
let cat = Cat { name: "кот".to_string() };
println!("{}", cat + dog);
}