pub struct WeightAndDistance(pub Fraction, pub u32);Expand description
Represents a thin structure storing the weight and distance associated with a candidate
Tuple Fields§
§0: Fraction§1: u32Implementations§
Source§impl WeightAndDistance
impl WeightAndDistance
Sourcepub fn repr(&self) -> u32
pub fn repr(&self) -> u32
A representation method which allows distinguishment between structures
on a given f(weight, distance) = weight² × distance function,
returning a u32 representation of the structure.
Using a quadratic road-class weighting ensures that the Dijkstra path finder strongly penalises lower-quality roads (e.g. offramps / MotorwayLink), preventing short detours through lower-class roads from being preferred over longer, same-class routes.
With quadratic weighting a MotorwayLink detour (weight=2) has an effective cost 4× that of an equal-length motorway segment (weight=1), so the direct motorway is preferred unless the detour is less than one quarter of the motorway path length.
pub const fn new(frac: Fraction, weight: u32) -> Self
Trait Implementations§
Source§impl Add for WeightAndDistance
impl Add for WeightAndDistance
Source§impl Clone for WeightAndDistance
impl Clone for WeightAndDistance
Source§fn clone(&self) -> WeightAndDistance
fn clone(&self) -> WeightAndDistance
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WeightAndDistance
impl Debug for WeightAndDistance
Source§impl Hash for WeightAndDistance
impl Hash for WeightAndDistance
Source§impl Ord for WeightAndDistance
impl Ord for WeightAndDistance
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for WeightAndDistance
impl PartialEq for WeightAndDistance
Source§impl PartialOrd for WeightAndDistance
impl PartialOrd for WeightAndDistance
Source§impl Zero for WeightAndDistance
impl Zero for WeightAndDistance
impl Copy for WeightAndDistance
impl Eq for WeightAndDistance
Auto Trait Implementations§
impl Freeze for WeightAndDistance
impl RefUnwindSafe for WeightAndDistance
impl Send for WeightAndDistance
impl Sync for WeightAndDistance
impl Unpin for WeightAndDistance
impl UnsafeUnpin for WeightAndDistance
impl UnwindSafe for WeightAndDistance
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
self to key and returns true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more