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

        let optimal_start = end - duration;
        return_on_some!(self.try_schedule_trivial_cases(optimal_start, end, Rc::clone(&data)));

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

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

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