From e372a5348ccec88524c119425fd64c1428da34ac Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 21 Sep 2024 19:02:46 +0100 Subject: [PATCH] rust post --- content/post/2024-09-21-RustTraits.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/content/post/2024-09-21-RustTraits.md b/content/post/2024-09-21-RustTraits.md index f1e605f..9d67095 100644 --- a/content/post/2024-09-21-RustTraits.md +++ b/content/post/2024-09-21-RustTraits.md @@ -18,6 +18,11 @@ Traits can be added to types to allow them to do something, as if these were cla implemented. So if I want to check if an i32 is divisible by 7, I can add: ``` +trait Sevens { + fn divisible_by_seven(&self) -> bool ; + fn is_seven(&self) -> bool ; +} + impl Sevens for i32 { fn divisible_by_seven(&self) -> bool{ self%7 == 0