String.UTF8View.Index

struct String.UTF8View.Index

A position in a String.UTF8View

Inheritance Equatable, ForwardIndexType, _ForwardIndexType, _Incrementable View Protocol Hierarchy →
Import import Swift

Initializers

init(_: String.Index, within: String.UTF8View)

Construct the position in utf8 that corresponds exactly to characterIndex.

Requires: characterIndex is an element of indices(String(utf8)!).

Declaration

init(_ characterIndex: String.Index, within utf8: String.UTF8View)
init(_: UnicodeScalarIndex, within: String.UTF8View)

Construct the position in utf8 that corresponds exactly to unicodeScalarIndex.

Requires: unicodeScalarIndex is an element of indices(String(utf8)!.unicodeScalars).

Declaration

init(_ unicodeScalarIndex: UnicodeScalarIndex, within utf8: String.UTF8View)
init?(_:within:)

Construct the position in utf8 that corresponds exactly to utf16Index. If no such position exists, the result is nil.

Requires: utf8Index is an element of indices(String(utf16)!.utf8).

Declaration

init?(_ utf16Index: UTF16Index, within utf8: String.UTF8View)

Instance Methods

func samePositionIn(_: String)

Return the position in characters that corresponds exactly to self, or if no such position exists, nil.

Requires: self is an element of indices(characters.utf8).

Declaration

func samePositionIn(characters: String) -> String.Index?
func samePositionIn(_: String.UTF16View)

Return the position in utf16 that corresponds exactly to self, or if no such position exists, nil.

Requires: self is an element of indices(String(utf16)!.utf8).

Declaration

func samePositionIn(utf16: String.UTF16View) -> String.UTF16View.Index?
func samePositionIn(_: String.UnicodeScalarView)

Return the position in unicodeScalars that corresponds exactly to self, or if no such position exists, nil.

Requires: self is an element of indices(String(unicodeScalars).utf8).

Declaration

func samePositionIn(unicodeScalars: String.UnicodeScalarView) -> UnicodeScalarIndex?
func successor()

Returns the next consecutive value after self.

Requires: the next value is representable.

Declaration

func successor() -> String.UTF8View.Index