Skip to content

Commit 0eca37d

Browse files
committed
chore: remove usage of deprecated
1 parent 88db405 commit 0eca37d

File tree

4 files changed

+5
-14
lines changed

4 files changed

+5
-14
lines changed

builtin/stringview.mbt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ fn StringView::make_view(str : String, start : Int, end : Int) -> StringView = "
3131
/// Returns the charcode(UTF-16 code unit) at the given index.
3232
///
3333
/// This method has O(1) complexity.
34-
///
35-
/// # Example
36-
///
37-
/// ```mbt
38-
/// let str = "Hello🤣🤣🤣"
39-
/// let view = str.view(start_offset = str.offset_of_nth_char(1).unwrap(), end_offset = str.offset_of_nth_char(6).unwrap())
40-
/// inspect(view[0].to_char(), content="Some('e')")
41-
/// inspect(view[4], content="55358")
42-
/// ```
4334
#alias("_[_]")
4435
#deprecated("Use `code_unit_at` instead which returns UInt16")
4536
pub fn StringView::at(self : StringView, index : Int) -> Int {

encoding/utf16/encode.mbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ pub fn encode(
3838
arr[0] = 0xFE
3939
arr[1] = 0xFF
4040
for i in 0..<str.length() {
41-
let code_unit = str[i]
41+
let code_unit = str.code_unit_at(i)
4242
arr[2 + i * 2] = (code_unit >> 8).to_byte()
4343
arr[2 + i * 2 + 1] = (code_unit & 0xFF).to_byte()
4444
}
4545
arr.unsafe_reinterpret_as_bytes()
4646
} else {
4747
let arr = FixedArray::make(str.length() * 2, b'\x00')
4848
for i in 0..<str.length() {
49-
let code_unit = str[i]
49+
let code_unit = str.code_unit_at(i)
5050
arr[i * 2] = (code_unit >> 8).to_byte()
5151
arr[i * 2 + 1] = (code_unit & 0xFF).to_byte()
5252
}

string/regex/internal/regexp/internal/vm/impl.mbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ fn add_thread(
117117
let assertion = match pred {
118118
BeginText => sp == 0
119119
EndText => sp == content.length()
120-
BeginLine => sp == 0 || content[sp - 1] == '\n'
121-
EndLine => sp == content.length() || content[sp] == '\n'
120+
BeginLine => sp == 0 || content.code_unit_at(sp - 1) == '\n'
121+
EndLine => sp == content.length() || content.code_unit_at(sp) == '\n'
122122
WordBoundary =>
123123
is_word_char_at(content, sp - 1) != is_word_char_at(content, sp)
124124
NoWordBoundary =>

string/view_test.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ test "StringView add" {
10441044
test "panic view op_get out of bounds" {
10451045
let str = "Hello"
10461046
let view = str.view(start_offset=0, end_offset=5)
1047-
view[5] |> ignore
1047+
view.code_unit_at(5) |> ignore
10481048
}
10491049

10501050
// Added test to cover start index pointing to trailing surrogate

0 commit comments

Comments
 (0)