Changed an argument to a reference

This commit is contained in:
daladim 2021-03-21 19:27:55 +01:00
parent f29aca941b
commit bb2122db6b
5 changed files with 8 additions and 8 deletions

View file

@ -187,8 +187,8 @@ impl CalDavSource<CachedCalendar> for Cache {
)
}
async fn get_calendar(&self, id: CalendarId) -> Option<Arc<Mutex<CachedCalendar>>> {
self.data.calendars.get(&id).map(|arc| arc.clone())
async fn get_calendar(&self, id: &CalendarId) -> Option<Arc<Mutex<CachedCalendar>>> {
self.data.calendars.get(id).map(|arc| arc.clone())
}
}

View file

@ -220,11 +220,11 @@ impl CalDavSource<RemoteCalendar> for Client {
}
async fn get_calendar(&self, id: CalendarId) -> Option<Arc<Mutex<RemoteCalendar>>> {
async fn get_calendar(&self, id: &CalendarId) -> Option<Arc<Mutex<RemoteCalendar>>> {
self.cached_replies.lock().unwrap()
.calendars
.as_ref()
.and_then(|cals| cals.get(&id))
.and_then(|cals| cals.get(id))
.map(|cal| cal.clone())
}
}

View file

@ -68,7 +68,7 @@ where
for (id, cal_server) in cals_server {
let mut cal_server = cal_server.lock().unwrap();
let cal_local = match self.local.get_calendar(id).await {
let cal_local = match self.local.get_calendar(&id).await {
None => {
log::error!("TODO: implement here");
continue;

View file

@ -15,7 +15,7 @@ pub trait CalDavSource<T: PartialCalendar> {
/// This function may trigger an update (that can be a long process, or that can even fail, e.g. in case of a remote server)
async fn get_calendars(&self) -> Result<HashMap<CalendarId, Arc<Mutex<T>>>, Box<dyn Error>>;
/// Returns the calendar matching the ID
async fn get_calendar(&self, id: CalendarId) -> Option<Arc<Mutex<T>>>;
async fn get_calendar(&self, id: &CalendarId) -> Option<Arc<Mutex<T>>>;
}
pub trait SyncSlave {

View file

@ -104,7 +104,7 @@ async fn populate_test_provider() -> Provider<Cache, CachedCalendar, Cache, Cach
// Step 2
// Edit the server calendar
let cal_server = server.get_calendar(cal_id.clone()).await.unwrap();
let cal_server = server.get_calendar(&cal_id).await.unwrap();
let mut cal_server = cal_server.lock().unwrap();
cal_server.delete_item(&task_b_id).await.unwrap();
@ -134,7 +134,7 @@ async fn populate_test_provider() -> Provider<Cache, CachedCalendar, Cache, Cach
// Step 3
// Edit the local calendar
let cal_local = local.get_calendar(cal_id).await.unwrap();
let cal_local = local.get_calendar(&cal_id).await.unwrap();
let mut cal_local = cal_local.lock().unwrap();
cal_local.delete_item(&task_c_id).await.unwrap();