fn schedule_according_to_myrjam(
        &mut self,
        start: DateTime<Utc>,
        mut tasks: Vec<Rc<TaskT>>,
    ) -> Result<(), Error<TaskT>> {
        // Start by scheduling the least important tasks closest to the deadline, and so on.
        tasks.sort_by_key(|task| task.importance());
        for task in tasks {
            if task.deadline() < start + task.duration() {
                return Err(Error::DeadlineMissed {
                    task: (*task).clone(),
                    tense: if task.deadline() < start {
                        "missed"
                    } else {
                        "will miss"
                    },
                });
            }
            if !self.schedule_close_before(
                task.deadline(),
                task.duration(),
                Some(start),
                Item::Task(Rc::clone(&task)),
            ) {
                return Err(Error::NotEnoughTime {
                    task: (*task).clone(),
                });
            }
        }
        // Next, shift the all tasks towards the present, filling up the gaps.
        let entries = self
            .iter()
            .map(|entry| Entry {
                start: entry.start,
                end: entry.end,
                data: (*entry.data).clone(),
            })
            .collect::<Vec<_>>();
        for entry in entries {
            if let Item::Task(ref task) = entry.data {
                let scheduled_entry = self
                    .unschedule(&entry.data)
                    .ok_or_else(|| Error::Internal("I couldn't unschedule a task"))?;
                if !self.schedule_close_after(
                    start,
                    task.duration(),
                    Some(scheduled_entry.end),
                    scheduled_entry.data,
                ) {
                    return Err(Error::Internal("I couldn't reschedule a task"));
                }
            }
        }
        Ok(())
    }
/// Schedules `tasks` according to deadline first and then according to importance.
///
/// First, all tasks --- starting with the least important until the most important --- are
/// scheduled as close as possible to their deadline. Next, all tasks are put as close to the
/// present as possible, keeping the order from the first scheduling phase.
///
/// This algorithm is how Myrjam Van de Vijver does her personal scheduling. A benefit of doing
/// it this way, is that it is highly robust against contingencies like falling sick. A
/// disadvantage is that it gives more priority to urgent but less important tasks than to
/// important but less urgent tasks.
Schedules `tasks` according to deadline first and then according to importance.

This algorithm is how Myrjam Van de Vijver does her personal scheduling. A benefit of doing
it this way, is that it is highly robust against contingencies like falling sick. A
disadvantage is that it gives more priority to urgent but less important tasks than to
important but less urgent tasks.
Schedules ` tasks ` according to deadline first and then according to importance . This algorithm is how Myrjam Van de Vijver does her personal scheduling . A benefit of doing it this way is that it is highly robust against contingencies like falling sick . A disadvantage is that it gives more priority to urgent but less important tasks than to important but less urgent tasks .
fn schedule_according_to_myrjam(
        &mut self,
        start: DateTime<Utc>,
        mut tasks: Vec<Rc<TaskT>>,
    ) -> Result<(), Error<TaskT>> {
        // Start by scheduling the least important tasks closest to the deadline, and so on.
        tasks.sort_by_key(|task| task.importance());
        for task in tasks {
            if task.deadline() < start + task.duration() {
                return Err(Error::DeadlineMissed {
                    task: (*task).clone(),
                    tense: if task.deadline() < start {
                        "missed"
                    } else {
                        "will miss"
                    },
                });
            }
            if !self.schedule_close_before(
                task.deadline(),
                task.duration(),
                Some(start),
                Item::Task(Rc::clone(&task)),
            ) {
                return Err(Error::NotEnoughTime {
                    task: (*task).clone(),
                });
            }
        }
        // Next, shift the all tasks towards the present, filling up the gaps.
        let entries = self
            .iter()
            .map(|entry| Entry {
                start: entry.start,
                end: entry.end,
                data: (*entry.data).clone(),
            })
            .collect::<Vec<_>>();
        for entry in entries {
            if let Item::Task(ref task) = entry.data {
                let scheduled_entry = self
                    .unschedule(&entry.data)
                    .ok_or_else(|| Error::Internal("I couldn't unschedule a task"))?;
                if !self.schedule_close_after(
                    start,
                    task.duration(),
                    Some(scheduled_entry.end),
                    scheduled_entry.data,
                ) {
                    return Err(Error::Internal("I couldn't reschedule a task"));
                }
            }
        }
        Ok(())
    }
fn schedule_according_to_myrjam ( & mut self , start : DateTime < Utc > , mut tasks : Vec < Rc < TaskT > > , ) -> Result < ( ) , Error < TaskT > > { // Start by scheduling the least important tasks closest to the deadline, and so on. tasks . sort_by_key ( | task | task . importance ( ) ) ; for task in tasks { if task . deadline ( ) < start + task . duration ( ) { return Err ( Error :: DeadlineMissed { task : ( * task ) . clone ( ) , tense : if task . deadline ( ) < start { " " } else { " " } , } ) ; } if ! self . schedule_close_before ( task . deadline ( ) , task . duration ( ) , Some ( start ) , Item :: Task ( Rc :: clone ( & task ) ) , ) { return Err ( Error :: NotEnoughTime { task : ( * task ) . clone ( ) , } ) ; } } // Next, shift the all tasks towards the present, filling up the gaps. let entries = self . iter ( ) . map ( | entry | Entry { start : entry . start , end : entry . end , data : ( * entry . data ) . clone ( ) , } ) . collect :: < Vec < _ > > ( ) ; for entry in entries { if let Item :: Task ( ref task ) = entry . data { let scheduled_entry = self . unschedule ( & entry . data ) . ok_or_else ( | | Error :: Internal ( " " ) ) ? ; if ! self . schedule_close_after ( start , task . duration ( ) , Some ( scheduled_entry . end ) , scheduled_entry . data , ) { return Err ( Error :: Internal ( " " ) ) ; } } } Ok ( ( ) ) }
Schedules `tasks` according to deadline first and then according to importance.
Schedules ` tasks ` according to deadline first and then according to importance .
&mut self
start
DateTime<Utc>
tasks
Vec<Rc<TaskT>>
&mut self
start
DateTime<Utc>
tasks
Vec<Rc<TaskT>>