a-b-street/abstreet · error

not a lane

Error message

not a lane

What it means

Generic unwrapping helper on the Traversable enum: as_lane asserts the variant is Lane and this panic fires when a caller calls as_lane on a Traversable::Turn. The input at fault is the Traversable value itself — the caller should have used maybe_lane or matched on the enum first.

Solutions

  1. Use maybe_lane() and handle the None case instead of as_lane
  2. Match on the Traversable enum explicitly at the call site
  3. Fix the caller's logic so it only holds lane traversables when calling as_lane
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at map_model/src/traversable.rs:157 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of a-b-street/abstreet@0964f29315 (2026-09-13). Data as JSON: /api/errors/8a8c7fa74099b6a7. Report an issue: GitHub.

Appendix: source

Thrown at map_model/src/traversable.rs:157

impl Traversable {
    pub fn as_lane(&self) -> LaneID {
        match *self {
            Traversable::Lane(id) => id,
            Traversable::Turn(_) => panic!("not a lane"),
        }
    }

    pub fn as_turn(&self) -> TurnID {
        match *self {
            Traversable::Turn(id) => id,
            Traversable::Lane(_) => panic!("not a turn"),
        }
    }

View on GitHub (pinned to 0964f29315)