sendgc #103
| @ -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), | ||||
| 
				
					
						jake
						commented  should be  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 { | ||||
| 
				
					
						jake
						commented  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) | ||||
| 
				
					
						jake
						commented  
 `.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
 | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	
TODO: remove TODO