| 1 | #![no_std] |
| 2 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/; |
| 3 | |
| 4 | /// Copy bytes from `src` to `dst` |
| 5 | /// |
| 6 | /// Panics if `src.len() < dst.len()` |
| 7 | #[inline(always)] |
| 8 | pub fn copyrust-analyzer cargo byte-tools 0.3.0 copy().(src: &[u8], dst: &mut [u8]) { |
| 9 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dst.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() >= src.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 10 | unsafe { |
| 11 | ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::copy_nonoverlappingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/copy_nonoverlapping().(src.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().(), dst.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().(), src.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | /// Zero all bytes in `dst` |
| 16 | #[inline(always)] |
| 17 | pub fn zerorust-analyzer cargo byte-tools 0.3.0 zero().(dst: &mut [u8]) { |
| 18 | unsafe { |
| 19 | ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::write_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/write_bytes().(dst.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().(), 0, dst.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | /// Sets all bytes in `dst` equal to `value` |
| 24 | #[inline(always)] |
| 25 | pub fn setrust-analyzer cargo byte-tools 0.3.0 set().(dst: &mut [u8], value: u8) { |
| 26 | unsafe { |
| 27 | ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::write_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/write_bytes().(dst.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().(), value, dst.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 28 | } |
| 29 | } |