Skip to content

Commit 4c6de3d

Browse files
committed
Using manual implementation of <[u8]>::split_first_chunk::<4>
1 parent ba04b10 commit 4c6de3d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/de/mod.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,17 @@ impl<'a, 'de, 's> de::Deserializer<'de> for &'a mut Deserializer<'de, 's> {
506506
Some(b'r') => b'\r',
507507
Some(b't') => b'\t',
508508
Some(b'u') => {
509+
// TODO - Replace with `<[u8]>::split_first_chunk::<4>` once MSRV >= 1.77
510+
fn split_first_slice(
511+
bytes: &[u8],
512+
len: usize,
513+
) -> Option<(&[u8], &[u8])>
514+
{
515+
Some((bytes.get(..len)?, bytes.get(len..)?))
516+
}
517+
509518
let (escape_sequence, remaining_escaped_string_bytes) =
510-
escaped_string_bytes
511-
.as_slice()
512-
.split_first_chunk::<4>()
519+
split_first_slice(escaped_string_bytes.as_slice(), 4)
513520
.ok_or(Error::InvalidEscapeSequence)?;
514521

515522
escaped_string_bytes =

0 commit comments

Comments
 (0)