Replaced ...View by &...

This commit is contained in:
daladim 2021-02-18 12:07:38 +01:00
parent 58b96a89b0
commit 0cf441475d
2 changed files with 26 additions and 37 deletions

View file

@ -1,24 +1,21 @@
use crate::data::TaskView;
/// A Caldav Calendar
pub struct Calendar {
name: String,
tasks: Vec<TaskView>,
}
impl Calendar {
pub fn name() -> String {
self.name
}
pub fn tasks() -> Vec<TaskView> {
self.tasks
}
}
impl Drop for Calendar {
fn drop(&mut self) {
// TODO: display a warning in case some TaskViews still have a refcount > 0
}
}
use crate::data::Task;
/// A Caldav Calendar
pub struct Calendar {
name: String,
tasks: Vec<Task>,
}
impl Calendar {
pub fn name(&self) -> String {
self.name
}
pub fn tasks(&self) -> Vec<&Task> {
self.tasks
.iter()
.map(|t| &t)
.collect()
}
}

View file

@ -12,16 +12,11 @@ pub use calendar::Calendar;
pub use tasks::Task;
use client::Client;
// TODO: consider using references here
// (there will be no issue with still-borrowed-data when the DataSource is destroyed, but will it play well with sync stuff?)
type CalendarView = Arc<Calendar>;
type TaskView = Arc<Task>;
/// A Caldav data source
pub struct DataSource {
client: Option<Client>,
calendars: Vec<CalendarView>
calendars: Vec<Calendar>
}
impl DataSource {
@ -43,13 +38,10 @@ impl DataSource {
// TODO: how to handle conflicts?
}
pub fn calendars(&self) -> Vec<CalendarView> {
pub fn calendars(&self) -> Vec<&Calendar> {
self.calendars
}
}
impl Drop for DataSource {
fn drop(&mut self) {
// TODO: display a warning in case some CalendarViews still have a refcount > 0
.iter()
.map(|c| &c)
.collect()
}
}