Skip to content

Commit

Permalink
rust post
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham authored and Graham committed Sep 21, 2024
1 parent 56e60b3 commit e372a53
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions content/post/2024-09-21-RustTraits.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e372a53

Please sign in to comment.