fn insert_after<W>(
        &mut self,
        start: T,
        duration: W,
        max_end: Option<T>,
        data: Rc<D>,
    ) -> Option<T>
    where
        T: Ord + Add<W, Output = T>,
        W: Copy + Debug,
    {
        match self {
            Node::Leaf { .. } => None,
            Node::Intermediate { left, right, free } => {
                // If the start is inside the left child, try that first
                if start < free.start {
                    return_on_some!(left.insert_after(start, duration, max_end, Rc::clone(&data)))
                }
                // Second, try to insert it in the free range of the current node
                let start = max(start, free.start);
                if start + duration <= free.end
                    && max_end.map_or(true, |max_end| start + duration <= max_end)
                {
                    unchecked_insert(start, start + duration, data, right, free);
                    return Some(start);
                }
                // If max_end is contained in free, don't bother checking the right child
                if max_end.map_or(true, |max_end| max_end <= free.end) {
                    return None;
                }
                // Last, try to insert it in the right child
                right.insert_after(start, duration, max_end, data)
            }
        }
    }
/// Tries to insert a node with the given `data` and `duration` as a descendant of this node.
/// It must be scheduled as close after `start` as possible, but it cannot be scheduled later
/// than `max_end`, when given.
///
/// Returns the start of the scheduling if it succeeded, otherwise None
Tries to insert a node with the given `data` and `duration` as a descendant of this node.
It must be scheduled as close after `start` as possible, but it cannot be scheduled later
than `max_end`, when given.

Returns the start of the scheduling if it succeeded, otherwise None
Tries to insert a node with the given ` data ` and ` duration ` as a descendant of this node . It must be scheduled as close after ` start ` as possible but it cannot be scheduled later than ` max_end ` when given . Returns the start of the scheduling if it succeeded otherwise None
fn insert_after<W>(
        &mut self,
        start: T,
        duration: W,
        max_end: Option<T>,
        data: Rc<D>,
    ) -> Option<T>
    where
        T: Ord + Add<W, Output = T>,
        W: Copy + Debug,
    {
        match self {
            Node::Leaf { .. } => None,
            Node::Intermediate { left, right, free } => {
                // If the start is inside the left child, try that first
                if start < free.start {
                    return_on_some!(left.insert_after(start, duration, max_end, Rc::clone(&data)))
                }
                // Second, try to insert it in the free range of the current node
                let start = max(start, free.start);
                if start + duration <= free.end
                    && max_end.map_or(true, |max_end| start + duration <= max_end)
                {
                    unchecked_insert(start, start + duration, data, right, free);
                    return Some(start);
                }
                // If max_end is contained in free, don't bother checking the right child
                if max_end.map_or(true, |max_end| max_end <= free.end) {
                    return None;
                }
                // Last, try to insert it in the right child
                right.insert_after(start, duration, max_end, data)
            }
        }
    }
fn insert_after < W > ( & mut self , start : T , duration : W , max_end : Option < T > , data : Rc < D > , ) -> Option < T > where T : Ord + Add < W , Output = T > , W : Copy + Debug , { match self { Node :: Leaf { .. } => None , Node :: Intermediate { left , right , free } => { // If the start is inside the left child, try that first if start < free . start { return_on_some ! ( left insert_after ( start duration max_end Rc clone ( data ) ) ) } // Second, try to insert it in the free range of the current node let start = max ( start , free . start ) ; if start + duration <= free . end && max_end . map_or ( true , | max_end | start + duration <= max_end ) { unchecked_insert ( start , start + duration , data , right , free ) ; return Some ( start ) ; } // If max_end is contained in free, don't bother checking the right child if max_end . map_or ( true , | max_end | max_end <= free . end ) { return None ; } // Last, try to insert it in the right child right . insert_after ( start , duration , max_end , data ) } } }
Tries to insert a node with the given `data` and `duration` as a descendant of this node.
Tries to insert a node with the given ` data ` and ` duration ` as a descendant of this node .
&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>