pub fn trim_deadends(raw: &mut RawMap) {
    let mut remove_roads = BTreeSet::new();
    let mut remove_intersections = BTreeSet::new();
    for (id, i) in &raw.intersections {
        let roads = raw.roads_per_intersection(*id);
        if roads.len() != 1 || i.intersection_type == IntersectionType::Border {
            continue;
        }
        let road = &raw.roads[&roads[0]];
        if road.length() < SHORT_THRESHOLD
            && (is_cycleway(road, raw) || road.osm_tags.is(osm::HIGHWAY, "service"))
        {
            remove_roads.insert(roads[0]);
            remove_intersections.insert(*id);
        }
    }

    for r in remove_roads {
        raw.roads.remove(&r).unwrap();
    }
    for i in remove_intersections {
        raw.delete_intersection(i);
    }

    // It's possible we need to do this in a fixed-point until there are no changes, but meh.
    // Results look good so far.
}
/// Some cycleways intersect footways with detailed curb mapping. The current rules for figuring
/// out which walking paths also allow bikes are imperfect, so we wind up with short dead-end
/// "stubs." Trim those.
///
/// Also do the same thing for extremely short dead-end service roads.
Some cycleways intersect footways with detailed curb mapping. The current rules for figuring
out which walking paths also allow bikes are imperfect, so we wind up with short dead-end
"stubs." Trim those.

Also do the same thing for extremely short dead-end service roads.
Some cycleways intersect footways with detailed curb mapping . The current rules for figuring out which walking paths also allow bikes are imperfect so we wind up with short dead - end " stubs . " Trim those . Also do the same thing for extremely short dead - end service roads .
pub fn trim_deadends(raw: &mut RawMap) {
    let mut remove_roads = BTreeSet::new();
    let mut remove_intersections = BTreeSet::new();
    for (id, i) in &raw.intersections {
        let roads = raw.roads_per_intersection(*id);
        if roads.len() != 1 || i.intersection_type == IntersectionType::Border {
            continue;
        }
        let road = &raw.roads[&roads[0]];
        if road.length() < SHORT_THRESHOLD
            && (is_cycleway(road, raw) || road.osm_tags.is(osm::HIGHWAY, "service"))
        {
            remove_roads.insert(roads[0]);
            remove_intersections.insert(*id);
        }
    }
    for r in remove_roads {
        raw.roads.remove(&r).unwrap();
    }
    for i in remove_intersections {
        raw.delete_intersection(i);
    }
    // It's possible we need to do this in a fixed-point until there are no changes, but meh.
    // Results look good so far.
}
pub fn trim_deadends ( raw : & mut RawMap ) { let mut remove_roads = BTreeSet :: new ( ) ; let mut remove_intersections = BTreeSet :: new ( ) ; for ( id , i ) in & raw . intersections { let roads = raw . roads_per_intersection ( * id ) ; if roads . len ( ) != 1 || i . intersection_type == IntersectionType :: Border { continue ; } let road = & raw . roads [ & roads [ 0 ] ] ; if road . length ( ) < SHORT_THRESHOLD && ( is_cycleway ( road , raw ) || road . osm_tags . is ( osm :: HIGHWAY , " " ) ) { remove_roads . insert ( roads [ 0 ] ) ; remove_intersections . insert ( * id ) ; } } for r in remove_roads { raw . roads . remove ( & r ) . unwrap ( ) ; } for i in remove_intersections { raw . delete_intersection ( i ) ; } // It's possible we need to do this in a fixed-point until there are no changes, but meh. // Results look good so far. }
Some cycleways intersect footways with detailed curb mapping.
Some cycleways intersect footways with detailed curb mapping .
raw
&mut RawMap