sendgc #103

Closed
andy wants to merge 5 commits from sendgc into master
Showing only changes of commit ee7382e8e4 - Show all commits

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)]
Review

TODO: remove TODO

TODO: remove TODO
pub enum GuildcardError {
GuildcardAlreadyFriend(u32),
GuildcardAlreadyBlocked(u32),
GuildcardAlreadyFriend(UserAccountId),
GuildcardAlreadyBlocked(UserAccountId),
Outdated
Review

should be UserAccountId not u32 (or whatever proper not-number type is expected)

should be `UserAccountId` not `u32` (or whatever proper not-number type is expected)
GuildcardListFull,
}
@ -130,7 +129,6 @@ impl NewGuildCardDataEntity {
}
}
// TODO: implement this properly
#[derive(Clone, Debug)]
pub struct GuildCardDataEntity {
Outdated
Review

TODO: determine if this was implemented properly

TODO: determine if this was implemented properly
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)
Outdated
Review

.iter().position() might be preferable to .enumerate().find()?

`.iter().position()` might be preferable to `.enumerate().find()`?
.ok_or(GuildcardError::GuildcardListFull)?;
self.guildcard_data.friends[next_open_spot] = guildcard::GuildCard::from(new_friend);
Ok(()) // TODO: implement a real error
}