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
917
+
A slice consists of a string together with the start and end byte positions of a region of
918
918
interest. Actually extracting a substring requires copying and memory allocation, while many
919
-
substrings of the same underlying string may exist with very little overhead, and they are more
920
-
convenient than tracking the bounds by hand.
919
+
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.
921
920
922
921
`String.Slice` bundles proofs to ensure that the start and end positions always delineate a valid
923
922
string. For this reason, it should be preferred over `Substring`.
@@ -935,6 +934,9 @@ structure Slice where
935
934
instance : Inhabited Slice where
936
935
default := ⟨"", "".startValidPos, "".startValidPos, by simp [Pos.Raw.le_iff]⟩
937
936
937
+
/--
938
+
Returns a slice that contains the entire string.
939
+
-/
938
940
@[inline, expose]-- expose for the defeq `s.toSlice.str = s`.
0 commit comments