This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```rs | |
| // Based on: https://www.reddit.com/r/rust/comments/ehr8ct/announcing_impls_a_macro_to_determine_if_a_type/ | |
| // trait for T | |
| trait TTrate { | |
| const VALUE: bool = false; | |
| } | |
| impl<T> TTrate for T {} | |
| // custom trait |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::ops; | |
| #[derive(Debug, Default, Clone, Copy, Eq, Hash, PartialEq, PartialOrd, Ord)] | |
| pub struct U32(u32); | |
| impl ops::Add for U32 { | |
| type Output = Self; | |
| fn add(self, rhs: Self) -> Self { | |
| Self(self.0 + rhs.0) | |
| } |
OlderNewer