fn handle_accepted_conflicts(
        &mut self,
        req: &Request,
        map: &Map,
        maybe_cars_and_queues: Option<(&BTreeMap<CarID, Car>, &BTreeMap<Traversable, Queue>)>,
    ) -> bool {
        let turn = map.get_t(req.turn);
        let mut cycle_detected = false;
        let mut ok = true;
        for other in &self.state[&req.turn.parent].accepted {
            // Never short-circuit; always record all of the dependencies; it might help someone
            // else unstick things.
            if map.get_t(other.turn).conflicts_with(turn) {
                if self.break_turn_conflict_cycles {
                    if let AgentID::Car(c) = req.agent {
                        if let AgentID::Car(c2) = other.agent {
                            self.blocked_by.insert((c, c2));
                        }
                        if !cycle_detected {
                            if let Some(cycle) =
                                self.detect_conflict_cycle(c, maybe_cars_and_queues.unwrap())
                            {
                                // Allow the conflicting turn!
                                self.events.push(Event::Alert(
                                    AlertLocation::Intersection(req.turn.parent),
                                    format!("Turn conflict cycle involving {:?}", cycle),
                                ));
                                cycle_detected = true;
                            }
                        }
                    }
                }

                if !cycle_detected
                    && !allow_conflicting_turns(map.get_i(req.turn.parent).orig_id.osm_node_id)
                {
                    ok = false;
                }

                // It's never safe for two vehicles to go for the same lane.
                if turn.id.dst == other.turn.dst {
                    return false;
                }
            }
        }
        ok
    }
// If true, the request can go.
If true, the request can go.
If true the request can go .
fn handle_accepted_conflicts(
        &mut self,
        req: &Request,
        map: &Map,
        maybe_cars_and_queues: Option<(&BTreeMap<CarID, Car>, &BTreeMap<Traversable, Queue>)>,
    ) -> bool {
        let turn = map.get_t(req.turn);
        let mut cycle_detected = false;
        let mut ok = true;
        for other in &self.state[&req.turn.parent].accepted {
            // Never short-circuit; always record all of the dependencies; it might help someone
            // else unstick things.
            if map.get_t(other.turn).conflicts_with(turn) {
                if self.break_turn_conflict_cycles {
                    if let AgentID::Car(c) = req.agent {
                        if let AgentID::Car(c2) = other.agent {
                            self.blocked_by.insert((c, c2));
                        }
                        if !cycle_detected {
                            if let Some(cycle) =
                                self.detect_conflict_cycle(c, maybe_cars_and_queues.unwrap())
                            {
                                // Allow the conflicting turn!
                                self.events.push(Event::Alert(
                                    AlertLocation::Intersection(req.turn.parent),
                                    format!("Turn conflict cycle involving {:?}", cycle),
                                ));
                                cycle_detected = true;
                            }
                        }
                    }
                }
                if !cycle_detected
                    && !allow_conflicting_turns(map.get_i(req.turn.parent).orig_id.osm_node_id)
                {
                    ok = false;
                }
                // It's never safe for two vehicles to go for the same lane.
                if turn.id.dst == other.turn.dst {
                    return false;
                }
            }
        }
        ok
    }
fn handle_accepted_conflicts ( & mut self , req : & Request , map : & Map , maybe_cars_and_queues : Option < ( & BTreeMap < CarID , Car > , & BTreeMap < Traversable , Queue > ) > , ) -> bool { let turn = map . get_t ( req . turn ) ; let mut cycle_detected = false ; let mut ok = true ; for other in & self . state [ & req . turn . parent ] . accepted { // Never short-circuit; always record all of the dependencies; it might help someone // else unstick things. if map . get_t ( other . turn ) . conflicts_with ( turn ) { if self . break_turn_conflict_cycles { if let AgentID :: Car ( c ) = req . agent { if let AgentID :: Car ( c2 ) = other . agent { self . blocked_by . insert ( ( c , c2 ) ) ; } if ! cycle_detected { if let Some ( cycle ) = self . detect_conflict_cycle ( c , maybe_cars_and_queues . unwrap ( ) ) { // Allow the conflicting turn! self . events . push ( Event :: Alert ( AlertLocation :: Intersection ( req . turn . parent ) , format ! ( " " cycle ) , ) ) ; cycle_detected = true ; } } } } if ! cycle_detected && ! allow_conflicting_turns ( map . get_i ( req . turn . parent ) . orig_id . osm_node_id ) { ok = false ; } // It's never safe for two vehicles to go for the same lane. if turn . id . dst == other . turn . dst { return false ; } } } ok }
If true, the request can go.
If true the request can go .
&mut self
req
&Request
map
&Map
maybe_cars_and_queues
Option<(&BTreeMap<CarID, Car>, &BTreeMap<Traversable, Queue>)>
&mut self
req
&Request
map
&Map
maybe_cars_and_queues
Option<(&BTreeMap<CarID, Car>, &BTreeMap<Traversable, Queue>)>