Skip to content

Commit 03eb2f7

Browse files
authored
chore: deprecate String.toSubstring (#11232)
This PR deprecates `String.toSubstring` in favor of `String.toRawSubstring` (cf. #11154).
1 parent 36a6844 commit 03eb2f7

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

src/Init/Data/String/Defs.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,4 +631,12 @@ def Slice.Pos.byte {s : Slice} (pos : s.Pos) (h : pos ≠ s.endPos) : UInt8 :=
631631
theorem push_eq_append (c : Char) : String.push s c = s ++ singleton c := by
632632
simp
633633

634+
@[deprecated String.toRawSubstring (since := "2025-11-18")]
635+
def toSubstring (s : String) : Substring.Raw :=
636+
s.toRawSubstring
637+
638+
@[deprecated String.toRawSubstring' (since := "2025-11-18")]
639+
def toSubstring' (s : String) : Substring.Raw :=
640+
s.toRawSubstring'
641+
634642
end String

src/Init/Prelude.lean

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3517,14 +3517,6 @@ Converts a `String` into a `Substring` that denotes the entire string.
35173517
startPos := {}
35183518
stopPos := s.rawEndPos
35193519

3520-
/--
3521-
Converts a `String` into a `Substring` that denotes the entire string.
3522-
-/
3523-
@[inline] def String.toSubstring (s : String) : Substring.Raw where
3524-
str := s
3525-
startPos := {}
3526-
stopPos := s.rawEndPos
3527-
35283520
/--
35293521
Converts a `String` into a `Substring` that denotes the entire string.
35303522
@@ -3533,14 +3525,6 @@ This is a version of `String.toRawSubstring` that doesn't have an `@[inline]` an
35333525
def String.toRawSubstring' (s : String) : Substring.Raw :=
35343526
s.toRawSubstring
35353527

3536-
/--
3537-
Converts a `String` into a `Substring` that denotes the entire string.
3538-
3539-
This is a version of `String.toRawSubstring` that doesn't have an `@[inline]` annotation.
3540-
-/
3541-
def String.toSubstring' (s : String) : Substring.Raw :=
3542-
s.toRawSubstring
3543-
35443528
/--
35453529
This function will cast a value of type `α` to type `β`, and is a no-op in the
35463530
compiler. This function is **extremely dangerous** because there is no guarantee

0 commit comments

Comments
 (0)