Files
firezone/rust/connlib/etherparse-ext/src/slice_utils.rs
Thomas Eizinger 5566f1847f refactor(rust): move crates into a more sensical hierarchy (#9066)
The current `rust/` directory is a bit of a wild-west in terms of how
the crates are organised. Most of them are simply at the top-level when
in reality, they are all `connlib`-related. The Apple and Android FFI
crates - which are entrypoints in the Rust code are defined several
layers deep.

To improve the situation, we move around and rename several crates. The
end result is that all top-level crates / directories are:

- Either entrypoints into the Rust code, i.e. applications such as
Gateway, Relay or a Client
- Or crates shared across all those entrypoints, such as `telemetry` or
`logging`
2025-05-12 01:04:17 +00:00

18 lines
495 B
Rust

/// Writes the given byte-array to the slice at the specified index.
///
/// # Safety
///
/// `offset` + `bytes.len()` must be within the slice.
pub unsafe fn write_to_offset_unchecked<const N: usize>(
slice: &mut [u8],
offset: usize,
bytes: [u8; N],
) {
debug_assert!(offset + N <= slice.len());
let (_front, rest) = unsafe { slice.split_at_mut_unchecked(offset) };
let (target, _rest) = unsafe { rest.split_at_mut_unchecked(N) };
target.copy_from_slice(&bytes)
}