-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All elements of 0 sized types are equivalent within the type now. (#3362
- Loading branch information
Showing
4 changed files
with
76 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
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,44 @@ | ||
#[derive(Copy, Drop, storage_access::StorageAccess)] | ||
struct Node { | ||
left: u128, | ||
right: u128 | ||
} | ||
|
||
#[starknet::interface] | ||
trait ITree<TContractState> { | ||
fn sorted_list(ref self: TContractState, root: u128); | ||
} | ||
|
||
#[starknet::contract] | ||
mod ExampleFailure { | ||
use super::Node; | ||
use super::ITree; | ||
use array::{ArrayTrait, Array}; | ||
|
||
#[storage] | ||
struct Storage { | ||
nodes: LegacyMap::<u128, Node>, | ||
} | ||
|
||
#[generate_trait] | ||
impl Impl of MyTrait { | ||
fn append_in_order_nodes(self: @ContractState, ref list: Array<(u128, Node)>, at: u128) { | ||
let node = self.nodes.read(at); | ||
if (node.left != 0) { | ||
self.append_in_order_nodes(ref list, node.left); | ||
} | ||
list.append((at, node)); | ||
if (node.right != 0) { | ||
self.append_in_order_nodes(ref list, node.right); | ||
} | ||
} | ||
} | ||
|
||
#[external(v0)] | ||
impl Tree of ITree<ContractState> { | ||
fn sorted_list(ref self: ContractState, root: u128) { | ||
let mut in_order: Array<(u128, Node)> = ArrayTrait::new(); | ||
self.append_in_order_nodes(ref in_order, root); | ||
} | ||
} | ||
} |
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