When I have a [*]u8
pointer and a usize
length, how do I convert the pointer to a []u8
slice with the specified length?
Asked
Active
Viewed 563 times
4

Dull Bananas
- 892
- 7
- 29
1 Answers
7
Use the slice syntax on the [*]u8
pointer:
fn to_slice(pointer: [*]u8, len: usize) []u8 {
return pointer[0..len];
}

Dull Bananas
- 892
- 7
- 29