[SR-13937] Needless precondition in Collection distance #56334
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
standard library
Area: Standard library umbrella
Additional Detail from JIRA
md5: 79626c31d137f57975f0b894a587bfcd
Issue Description:
The precondition in
Collection.distance
that reads “Only BidirectionalCollections can have end come before start” fires even for {{BidirectionalCollection}} models unless the implementor of the collection is hyper-vigilant and implements their own distance method.We could solve this problem by adding a default implementation of distance for BidirectionalCollections, but we're already doing a test/branch even on collections that are non-bidirectional, to detect the precondition violation. We might as well just do the right thing in all cases.
#34981 takes a first crack at an implementation.
The text was updated successfully, but these errors were encountered: