fn schedule_close_after_<W>(
        &mut self,
        start: T,
        duration: W,
        max_end: Option<T>,
        data: Rc<D>,
    ) -> Option<T>
    where
        T: Add<W, Output = T> + Sub<W, Output = T>,
        W: Copy + Debug,
    {
        assert!(max_end.map_or(true, |max_end| start + duration <= max_end));

        let optimal_end = start + duration;
        return_on_some!(self.try_schedule_trivial_cases(start, optimal_end, Rc::clone(&data)));

        return_on_some!(self
            .root
            .as_mut()
            .expect("Internal error: root could not be taken as mut ref")
            .insert_after(start, duration, max_end, Rc::clone(&data)));

        // As last resort, try to schedule after current scope if max_end allows
        let scope = self
            .scope
            .as_mut()
            .expect("Internal error: scope could not be taken as ref");
        if max_end.map_or(true, |max_end| scope.end + duration <= max_end) {
            // Schedule on [scope.end, scope.end + duration]
            let start = scope.end;
            let end = scope.end + duration;
            let new_node = Node::Leaf { start, end, data };
            self.root = Some(Node::Intermediate {
                left: Box::new(
                    self.root
                        .take()
                        .expect("Internal error: root could not be taken"),
                ),
                right: Box::new(new_node),
                free: scope.end..scope.end,
            });
            self.scope = Some(scope.start..end);
            return Some(start);
        }

        None
    }
/// See `schedule_close_after` for details.
///
/// Returns the start of the scheduling if it succeeded, otherwise None
See `schedule_close_after` for details.
Returns the start of the scheduling if it succeeded, otherwise None
See ` schedule_close_after ` for details . Returns the start of the scheduling if it succeeded otherwise None
fn schedule_close_after_<W>(
        &mut self,
        start: T,
        duration: W,
        max_end: Option<T>,
        data: Rc<D>,
    ) -> Option<T>
    where
        T: Add<W, Output = T> + Sub<W, Output = T>,
        W: Copy + Debug,
    {
        assert!(max_end.map_or(true, |max_end| start + duration <= max_end));
        let optimal_end = start + duration;
        return_on_some!(self.try_schedule_trivial_cases(start, optimal_end, Rc::clone(&data)));
        return_on_some!(self
            .root
            .as_mut()
            .expect("Internal error: root could not be taken as mut ref")
            .insert_after(start, duration, max_end, Rc::clone(&data)));
        // As last resort, try to schedule after current scope if max_end allows
        let scope = self
            .scope
            .as_mut()
            .expect("Internal error: scope could not be taken as ref");
        if max_end.map_or(true, |max_end| scope.end + duration <= max_end) {
            // Schedule on [scope.end, scope.end + duration]
            let start = scope.end;
            let end = scope.end + duration;
            let new_node = Node::Leaf { start, end, data };
            self.root = Some(Node::Intermediate {
                left: Box::new(
                    self.root
                        .take()
                        .expect("Internal error: root could not be taken"),
                ),
                right: Box::new(new_node),
                free: scope.end..scope.end,
            });
            self.scope = Some(scope.start..end);
            return Some(start);
        }
        None
    }
fn schedule_close_after_ < W > ( & mut self , start : T , duration : W , max_end : Option < T > , data : Rc < D > , ) -> Option < T > where T : Add < W , Output = T > + Sub < W , Output = T > , W : Copy + Debug , { assert ! ( max_end map_or ( true max_end start duration max_end ) ) ; let optimal_end = start + duration ; return_on_some ! ( self try_schedule_trivial_cases ( start optimal_end Rc clone ( data ) ) ) ; return_on_some ! ( self root as_mut ( ) expect ( " " ) insert_after ( start duration max_end Rc clone ( data ) ) ) ; // As last resort, try to schedule after current scope if max_end allows let scope = self . scope . as_mut ( ) . expect ( " " ) ; if max_end . map_or ( true , | max_end | scope . end + duration <= max_end ) { // Schedule on [scope.end, scope.end + duration] let start = scope . end ; let end = scope . end + duration ; let new_node = Node :: Leaf { start , end , data } ; self . root = Some ( Node :: Intermediate { left : Box :: new ( self . root . take ( ) . expect ( " " ) , ) , right : Box :: new ( new_node ) , free : scope . end .. scope . end , } ) ; self . scope = Some ( scope . start .. end ) ; return Some ( start ) ; } None }
See `schedule_close_after` for details.
See ` schedule_close_after ` for details .
&mut self
start
T
duration
W
max_end
Option<T>
data
Rc<D>
&mut self
start
T
duration
W
max_end
Option<T>
data
Rc<D>