Created
October 4, 2022 14:00
-
-
Save devendranaga/7865b0f7d116c8799cddc62198caf4fe to your computer and use it in GitHub Desktop.
memcpy in rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn memcpy(src: &[u8], dst: &mut [u8], len: usize) { | |
let i: usize = 0; | |
while i < len { | |
dst[i] = src[i]; | |
} | |
} | |
fn main() { | |
let buf: [u8; 10] = [1; 10]; | |
let mut dst: [u8; 20] = [2; 20]; | |
memcpy(&buf, &mut dst, 10); | |
for i in dst { | |
println!("{}", i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment