Browse Source

this isn't a valid thing anymore

jake 4 years ago
committed by andy
parent
commit
3a5579a72e
  1. 3
      src/entity/gateway/inmemory.rs
  2. 3
      src/entity/gateway/postgres/postgres.rs
  3. 2
      src/lib.rs

3
src/entity/gateway/inmemory.rs

@ -168,7 +168,8 @@ impl EntityGateway for InMemoryGateway {
async fn get_characters_by_user(&self, user: &UserAccountEntity) -> Result<[Option<CharacterEntity>; 4], GatewayError> {
let characters = self.characters.lock().unwrap();
let mut chars = [None; 4];
const NONE: Option<CharacterEntity> = None;
let mut chars = [NONE; 4];
characters
.iter()
.filter(|(_, c)| c.user_id == user.id)

3
src/entity/gateway/postgres/postgres.rs

@ -229,7 +229,8 @@ impl EntityGateway for PostgresGateway {
let mut stream = sqlx::query_as::<_, PgCharacter>("select * from player_character where user_account = $1 and slot < 4 order by slot")
.bind(user.id.0)
.fetch(&self.pool);
let mut result = [None; 4];
const NONE: Option<CharacterEntity> = None;
let mut result = [NONE; 4];
while let Some(character) = stream.try_next().await? {
let index = character.slot as usize;
result[index] = Some(character.into())

2
src/lib.rs

@ -1,7 +1,7 @@
#![allow(incomplete_features)]
#![feature(const_generics)]
#![feature(maybe_uninit_extra)]
#![feature(const_in_array_repeat_expressions)]
#![feature(inline_const)]
#![feature(drain_filter)]
#![feature(or_patterns)]

Loading…
Cancel
Save