<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I’d like to propose we add a function to Range<T> which allows transforming its bounds (both bounds, by the same transform). This would come in handy in many situations involving type conversions or bounds mutations:<div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Courier" class="">// duplicated on CountableRange</font></div><div class=""><font face="Courier" class="">extension Range {</font></div><div class=""><font face="Courier" class=""> func mapRange<T: Comparable>(_ transform: (Bound) throws -> T) rethrows -> Range<T> {</font></div><div class=""><font face="Courier" class=""> return try transform(lowerBound)..<(try transform(upperBound))</font></div><div class=""><font face="Courier" class=""> }</font></div><div class=""><font face="Courier" class="">}</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">// Type conversion:</font></div><div class=""><font face="Courier" class="">(myWrappedVal..<myOtherWrappedVal).mapRange { $0.sourceValue }</font></div><div class=""><font face="Courier" class="">// Shifting:</font></div><div class=""><font face="Courier" class="">(5..<15).mapRange { $0 + offset }</font></div></blockquote><div class=""><br class=""></div><div class="">Is there some reason why this would not be desirable? It’s a convenience addition, sure, but it is <i class="">very</i> convenient if you use generic code with lots of Ranges and wrapping abstractions.</div><div class=""><br class=""></div><div class="">- Karl</div></body></html>