rustls/
polyfill.rs

1/// Non-panicking `let (nonce, ciphertext) = ciphertext.split_at(...)`.
2// TODO(XXX): remove once MSRV reaches 1.80
3#[allow(dead_code)] // Complicated conditional compilation guards elided
4pub(crate) fn try_split_at(slice: &[u8], mid: usize) -> Option<(&[u8], &[u8])> {
5    match mid > slice.len() {
6        true => None,
7        false => Some(slice.split_at(mid)),
8    }
9}