Created
March 14, 2023 11:11
-
-
Save DavideSilva/b32d529f6dde1b60e637dee56050524b to your computer and use it in GitHub Desktop.
This file contains 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
#[derive(Copy, Drop)] | |
struct MyStruct { | |
val: felt, | |
} | |
trait MyTrait<T> { | |
fn is_green(self: @T) -> bool; | |
} | |
impl RGBImpl of MyTrait::<MyStruct> { | |
fn is_green(self: @MyStruct) -> bool { | |
*self.val == 1 | |
} | |
} | |
#[test] | |
fn assert_is_green() { | |
let green = MyStruct {val: 1}; | |
assert(green.is_green(), 'not green'); // <- This gives compiler error "Method `is_green` not found on type | |
assert((@green).is_green(), 'not green'); // <- This works | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment