Skip to content

Commit

Permalink
struct equality has been implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriscbr committed Aug 2, 2023
1 parent 309af1e commit dc4665c
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions main.w
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@ bring cloud;

// --- utils ---

// TODO: https://github.com/winglang/wing/issues/2939
let _equalAttributes = inflight (a: ddb.Attribute, b: ddb.Attribute): bool => {
return a.type == b.type && a.value == b.value;
};

// Check if an array of items contains an item with the given attributes
let containsItem = inflight (items: Array<Map<ddb.Attribute>>, attributes: Map<ddb.Attribute>): bool => {
for i in items {
let var matches = true;
for key in attributes.keys() {
if !_equalAttributes(i.get(key), attributes.get(key)) {
if i.get(key) != attributes.get(key) {
matches = false;
break;
}
Expand All @@ -31,7 +26,7 @@ let findItem = inflight (items: Array<Map<ddb.Attribute>>, attributes: Map<ddb.A
for i in items {
let var matches = true;
for key in attributes.keys() {
if !_equalAttributes(i.get(key), attributes.get(key)) {
if i.get(key) != attributes.get(key) {
matches = false;
break;
}
Expand Down

0 comments on commit dc4665c

Please sign in to comment.