Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

Commit

Permalink
refactor: run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboy-bebug committed Dec 17, 2021
1 parent d760613 commit 3b64a3e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
15 changes: 9 additions & 6 deletions src/brackets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ where
index_vector.push((start, end));
}

BracketsTransient { index_vector, _phantom: PhantomData }
BracketsTransient {
index_vector,
_phantom: PhantomData,
}
}
}

Expand Down Expand Up @@ -151,7 +154,7 @@ where
// check all brackets if key is queued
for i in 0..self.index_vector.len() {
if N::contains_key(i as Bracket, &item_key) {
return false
return false;
}
}

Expand All @@ -178,7 +181,7 @@ where
/// Will remove the item, but will not update the bounds in storage.
fn pop(&mut self, bracket: Bracket) -> Option<Item> {
if self.is_empty(bracket) {
return None
return None;
}

let (mut v_start, v_end) = self.index_vector[bracket as usize];
Expand All @@ -205,9 +208,9 @@ where
let (v_start, v_end) = self.index_vector[bracket as usize];

if v_start <= v_end {
return v_end - v_start
return v_end - v_start;
} else {
return (BufferIndex::MAX - v_start) + v_end
return (BufferIndex::MAX - v_start) + v_end;
}
}

Expand All @@ -216,7 +219,7 @@ where
// check all brackets if key is queued
for i in 0..self.index_vector.len() {
if N::contains_key(i as Bracket, &item_key) {
return true
return true;
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
let player = PlayerStruct { account };
// duplicate check if we can add key to the queue
if !queue.push(bracket, player.account.clone(), player.clone()) {
return false
return false;
}

Self::deposit_event(Event::Queued(player));
Expand Down Expand Up @@ -195,23 +195,23 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
for i in 0..Self::brackets_count() {
// skip if bracket is empty
if queue.size(i) == 0 {
continue
continue;
}
// iterate for each slot occupied and fill, till player match size reached
for _j in 0..queue.size(i) {
if brackets.len() == max_players as usize {
break
break;
}
brackets.push(i);
}
// leave if brackets is filled with brackets
if brackets.len() == max_players as usize {
break
break;
}
}
// vec not filled with enough brackets leave
if brackets.len() < max_players as usize {
return result
return result;
}

// pop from the harvested brackets players
Expand Down
5 changes: 4 additions & 1 deletion src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,8 @@ impl pallet_matchmaker::Config for Test {

// Build genesis storage according to the mock runtime.
pub fn new_test_ext() -> sp_io::TestExternalities {
system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
system::GenesisConfig::default()
.build_storage::<Test>()
.unwrap()
.into()
}

0 comments on commit 3b64a3e

Please sign in to comment.