From 9dea46b5e66eb54746b251d8950b2367c49be23d Mon Sep 17 00:00:00 2001 From: hybrid Date: Wed, 11 Nov 2026 17:16:48 +0300 Subject: add: supertraits, ext_traits, pancakes, hello, hello_macro --- src/supertraits/Cargo.toml | 6 ++++++ src/supertraits/src/.#main.rs | 1 + src/supertraits/src/main.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 src/supertraits/Cargo.toml create mode 120000 src/supertraits/src/.#main.rs create mode 100644 src/supertraits/src/main.rs (limited to 'src/supertraits') diff --git a/src/supertraits/Cargo.toml b/src/supertraits/Cargo.toml new file mode 100644 index 0000000..3c073ab --- /dev/null +++ b/src/supertraits/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "supertraits" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/src/supertraits/src/.#main.rs b/src/supertraits/src/.#main.rs new file mode 120000 index 0000000..e886a79 --- /dev/null +++ b/src/supertraits/src/.#main.rs @@ -0,0 +1 @@ +hybrid@polar.514225:1793336784 \ No newline at end of file diff --git a/src/supertraits/src/main.rs b/src/supertraits/src/main.rs new file mode 100644 index 0000000..3053c5a --- /dev/null +++ b/src/supertraits/src/main.rs @@ -0,0 +1,42 @@ +use std::fmt; + +trait OutlinePrint: fmt::Display { + fn outline_print(&self) { + let output = self.to_string(); + let len = output.len(); + + println!("{}", "*".repeat(len + 4)); + println!("*{}*", " ".repeat(len + 2)); + println!("* {output} *"); + println!("*{}*", " ".repeat(len + 2)); + println!("{}", "*".repeat(len + 4)); + } +} + +struct Point { + x: i32, + y: i32, +} + +impl Point { + fn new() -> Point { + Point { + x: 0, + y: 0, + } + } +} + +impl fmt::Display for Point { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "({}, {})" , self.x, self.y) + } +} + +impl OutlinePrint for Point {} + +fn main() { + let point = Point::new(); + + OutlinePrint::outline_print(&point); +} -- cgit v1.3.1