-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved trait implementation to separate test.
- Loading branch information
Showing
6 changed files
with
47 additions
and
35 deletions.
There are no files selected for viewing
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
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
40 changes: 40 additions & 0 deletions
40
crates/lang/macro/tests/ui/pass/08-flipper-as-dependency-trait.rs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use ink_lang as ink; | ||
|
||
#[ink::contract(compile_as_dependency = true)] | ||
mod flipper { | ||
#[ink_lang::trait_definition] | ||
pub trait FlipperTrait { | ||
#[ink(constructor)] | ||
fn new() -> Self; | ||
|
||
#[ink(message)] | ||
fn flip(&mut self); | ||
|
||
#[ink(message)] | ||
fn get(&self) -> bool; | ||
} | ||
|
||
#[ink(storage)] | ||
pub struct Flipper { | ||
value: bool, | ||
} | ||
|
||
impl FlipperTrait for Flipper { | ||
#[ink(constructor)] | ||
fn new() -> Self { | ||
Self::default() | ||
} | ||
|
||
#[ink(message)] | ||
fn flip(&mut self) { | ||
self.value = !self.value; | ||
} | ||
|
||
#[ink(message)] | ||
fn get(&self) -> bool { | ||
self.value | ||
} | ||
} | ||
} | ||
|
||
fn main() {} |
File renamed without changes.
File renamed without changes.
File renamed without changes.