From 7c6f1a7f9b7bbc1ebfa037604b402aa6caf9d135 Mon Sep 17 00:00:00 2001 From: sofia Date: Sun, 27 Jul 2025 18:37:10 +0300 Subject: [PATCH] Make assoc function example more extreme --- examples/associated_functions.reid | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/associated_functions.reid b/examples/associated_functions.reid index 9421ad8..d67b852 100644 --- a/examples/associated_functions.reid +++ b/examples/associated_functions.reid @@ -1,3 +1,7 @@ +import std::print; +import std::from_str; +import std::String; + struct Otus { field: u32, } @@ -8,7 +12,17 @@ impl Otus { } } +impl i32 { + fn test(&self) -> u32 { + 43 + } +} + fn main() -> u32 { let otus = Otus { field: 17 }; + let num = 54; + print(from_str("otus: ") + Otus::test(&otus) as u64); + print(from_str("i32: ") + i32::test(&num) as u64); + return Otus::test(&otus); }