pr changes

This commit is contained in:
andy 2022-04-30 19:35:15 +00:00
parent 5898a8120a
commit ee7382e8e4

View File

@ -11,11 +11,10 @@ pub struct UserAccountId(pub u32);
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct UserSettingsId(pub u32);
// TODO: use these
#[derive(Debug)]
pub enum GuildcardError {
GuildcardAlreadyFriend(u32),
GuildcardAlreadyBlocked(u32),
GuildcardAlreadyFriend(UserAccountId),
GuildcardAlreadyBlocked(UserAccountId),
GuildcardListFull,
}
@ -130,7 +129,6 @@ impl NewGuildCardDataEntity {
}
}
// TODO: implement this properly
#[derive(Clone, Debug)]
pub struct GuildCardDataEntity {
pub user_id: UserAccountId,
@ -148,10 +146,8 @@ impl GuildCardDataEntity {
pub fn add_friend(&mut self, new_friend: &GuildcardAccept) -> Result<(), GuildcardError> {
let next_open_spot = self.guildcard_data.friends
.iter()
.enumerate()
.find(|(_i, g)| g.id == 0)
.ok_or(GuildcardError::GuildcardListFull)?
.0;
.position(|&g| g.id == 0)
.ok_or(GuildcardError::GuildcardListFull)?;
self.guildcard_data.friends[next_open_spot] = guildcard::GuildCard::from(new_friend);
Ok(()) // TODO: implement a real error
}