Browse Source

Replaced ...View by &...

github_actions
daladim 5 years ago
parent
commit
0cf441475d
  1. 17
      src/data/calendar.rs
  2. 18
      src/data/mod.rs

17
src/data/calendar.rs

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

18
src/data/mod.rs

@ -12,16 +12,11 @@ pub use calendar::Calendar;
pub use tasks::Task; pub use tasks::Task;
use client::Client; 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 /// A Caldav data source
pub struct DataSource { pub struct DataSource {
client: Option<Client>, client: Option<Client>,
calendars: Vec<CalendarView> calendars: Vec<Calendar>
} }
impl DataSource { impl DataSource {
@ -43,13 +38,10 @@ impl DataSource {
// TODO: how to handle conflicts? // TODO: how to handle conflicts?
} }
pub fn calendars(&self) -> Vec<CalendarView> { pub fn calendars(&self) -> Vec<&Calendar> {
self.calendars self.calendars
} .iter()
} .map(|c| &c)
.collect()
impl Drop for DataSource {
fn drop(&mut self) {
// TODO: display a warning in case some CalendarViews still have a refcount > 0
} }
} }

Loading…
Cancel
Save