[stdlib] Make String.UTF8View bidirectional

This is a step along the way toward handling backward-compatiblity of UTF8View
slicing and preventing inadvertent creation of String instances that keep
inaccessible memory alive.
This commit is contained in:
Dave Abrahams
2017-07-17 11:26:35 -07:00
parent 56705736b4
commit e6519fbd2b
7 changed files with 116 additions and 38 deletions

View File

@@ -26,7 +26,7 @@ func test_UTF16ViewSubscriptByInt(x: String.UTF16View, i: Int, r: Range<Int>) {
func test_UTF8View(s: String.UTF8View, i: String.UTF8View.Index, d: Int) {
_ = s.index(after: i) // OK
_ = s.index(before: i) // expected-error {{before:}} expected-note {{overloads}}
_ = s.index(before: i) // OK
_ = s.index(i, offsetBy: d) // OK
_ = s.index(i, offsetBy: d, limitedBy: i) // OK
_ = s.distance(from: i, to: i) // OK