fmt, fixes and additions
This commit is contained in:
@@ -26,7 +26,7 @@ impl AttendanceStatus {
|
||||
_ => Err(format!("Invalid attendance status: '{}'", s)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Convert an AttendanceStatus to a string
|
||||
pub fn to_string(&self) -> String {
|
||||
match self {
|
||||
@@ -134,7 +134,11 @@ impl Event {
|
||||
/// Adds an attendee to the event
|
||||
pub fn add_attendee(mut self, attendee: Attendee) -> Self {
|
||||
// Prevent duplicate attendees by contact_id
|
||||
if !self.attendees.iter().any(|a| a.contact_id == attendee.contact_id) {
|
||||
if !self
|
||||
.attendees
|
||||
.iter()
|
||||
.any(|a| a.contact_id == attendee.contact_id)
|
||||
{
|
||||
self.attendees.push(attendee);
|
||||
}
|
||||
self
|
||||
@@ -148,18 +152,18 @@ impl Event {
|
||||
|
||||
/// Updates the status of an existing attendee
|
||||
pub fn update_attendee_status(mut self, contact_id: u32, status: AttendanceStatus) -> Self {
|
||||
if let Some(attendee) = self.attendees.iter_mut().find(|a| a.contact_id == contact_id) {
|
||||
if let Some(attendee) = self
|
||||
.attendees
|
||||
.iter_mut()
|
||||
.find(|a| a.contact_id == contact_id)
|
||||
{
|
||||
attendee.status = status;
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Reschedules the event to new start and end times
|
||||
pub fn reschedule(
|
||||
mut self,
|
||||
new_start_time: i64,
|
||||
new_end_time: i64,
|
||||
) -> Self {
|
||||
pub fn reschedule(mut self, new_start_time: i64, new_end_time: i64) -> Self {
|
||||
// Basic validation: end_time should be after start_time
|
||||
if new_end_time > new_start_time {
|
||||
self.start_time = new_start_time;
|
||||
@@ -236,7 +240,8 @@ impl Calendar {
|
||||
|
||||
/// Removes an event from the calendar by its ID
|
||||
pub fn remove_event(mut self, event_id_to_remove: i64) -> Self {
|
||||
self.events.retain(|&event_id_in_vec| event_id_in_vec != event_id_to_remove);
|
||||
self.events
|
||||
.retain(|&event_id_in_vec| event_id_in_vec != event_id_to_remove);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user