You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A substring contains an string together with the start and end byte positions of a region of
1013
+
A slice consists of a string together with the start and end byte positions of a region of
1014
1014
interest. Actually extracting a substring requires copying and memory allocation, while many
1015
-
substrings of the same underlying string may exist with very little overhead, and they are more
1016
-
convenient than tracking the bounds by hand.
1015
+
slices of the same underlying string may exist with very little overhead. While this could be achieved by tracking the bounds by hand, the slice API is much more convenient.
1017
1016
1018
1017
`String.Slice` bundles proofs to ensure that the start and end positions always delineate a valid
1019
1018
string. For this reason, it should be preferred over `Substring`.
@@ -1031,6 +1030,9 @@ structure Slice where
1031
1030
instance : Inhabited Slice where
1032
1031
default := ⟨"", "".startValidPos, "".startValidPos, by simp [Pos.Raw.le_iff]⟩
1033
1032
1033
+
/--
1034
+
Returns a slice that contains the entire string.
1035
+
-/
1034
1036
@[inline, expose]-- expose for the defeq `s.toSlice.str = s`.
0 commit comments