summaryrefslogtreecommitdiffstats
path: root/src/supertraits
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/supertraits/Cargo.toml6
l---------src/supertraits/src/.#main.rs1
-rw-r--r--src/supertraits/src/main.rs42
3 files changed, 49 insertions, 0 deletions
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);
+}