Skip to content

Commit 99a8a5e

Browse files
committed
x
1 parent 84a81a5 commit 99a8a5e

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

rust/src/string.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ unsafe fn write_replaced_bytes(
275275
let mut src_pos = 0usize;
276276
let mut dst_pos = 0usize;
277277
while src_pos < src_len {
278-
if src_pos + find_len <= src_len && &src_bytes[src_pos..src_pos + find_len] == find_bytes {
278+
if src_pos + find_len <= src_len
279+
&& &src_bytes[src_pos..src_pos + find_len] == find_bytes
280+
{
279281
if replace_len > 0 {
280282
dst_bytes[dst_pos..dst_pos + replace_len].copy_from_slice(replace_bytes);
281283
}
@@ -990,7 +992,8 @@ pub extern "C" fn arduino_string_starts_with(
990992
prefix_len: c_uint,
991993
offset: c_uint,
992994
) -> bool {
993-
let Some((start, pat_len)) = checked_match_window(buffer, len, prefix, prefix_len, offset) else {
995+
let Some((start, pat_len)) = checked_match_window(buffer, len, prefix, prefix_len, offset)
996+
else {
994997
return false;
995998
};
996999
// SAFETY: ranges validated above.
@@ -1005,7 +1008,8 @@ pub extern "C" fn arduino_string_ends_with(
10051008
suffix_len: c_uint,
10061009
) -> bool {
10071010
let offset = len.saturating_sub(suffix_len);
1008-
let Some((start, pat_len)) = checked_match_window(buffer, len, suffix, suffix_len, offset) else {
1011+
let Some((start, pat_len)) = checked_match_window(buffer, len, suffix, suffix_len, offset)
1012+
else {
10091013
return false;
10101014
};
10111015
// SAFETY: ranges validated above.
@@ -1081,7 +1085,13 @@ pub extern "C" fn arduino_string_last_index_of_bytes(
10811085

10821086
// SAFETY: buffer/pat are non-null and caller provides readable ranges.
10831087
index_or_minus_one(unsafe {
1084-
last_index_of_bytes_from(buffer, len as usize, pat, pat_len as usize, from_index as usize)
1088+
last_index_of_bytes_from(
1089+
buffer,
1090+
len as usize,
1091+
pat,
1092+
pat_len as usize,
1093+
from_index as usize,
1094+
)
10851095
})
10861096
}
10871097

@@ -1146,7 +1156,8 @@ pub extern "C" fn arduino_string_replace_bytes(
11461156
return true;
11471157
}
11481158

1149-
let Some(new_len) = compute_replaced_len(current_len, find_len, replace_len, match_count) else {
1159+
let Some(new_len) = compute_replaced_len(current_len, find_len, replace_len, match_count)
1160+
else {
11501161
return false;
11511162
};
11521163
let tmp_size = (new_len as usize).saturating_add(1);
@@ -1262,7 +1273,8 @@ pub extern "C" fn arduino_string_get_bytes(
12621273
}
12631274

12641275
if copy_len > 0 {
1265-
let src = core::slice::from_raw_parts(buffer.add(index as usize).cast::<u8>(), copy_len);
1276+
let src =
1277+
core::slice::from_raw_parts(buffer.add(index as usize).cast::<u8>(), copy_len);
12661278
out_slice[..copy_len].copy_from_slice(src);
12671279
}
12681280
out_slice[copy_len] = 0;

0 commit comments

Comments
 (0)