How to c type in rust

It depends on what you want it to be! Something similar to the last post here would likely work for *mut u8: How to use void ** - #5 by mbrubeck.

If you want it to be a reference to a stack variable, you can simply do

let mut v: u8 = 0u8;
let ptr: *mut u8 = &mut v;

Note that the type is *mut u8 in Rust, not mut* u8.

However, this might not be useful. Usually, the only reason you would use *mut u8 is if you want to interact with a C api. So that C api dictates what you need. If this is your situation, what api or library are you trying to use?


If you aren't trying to use a C library, then I recommend using Rust references rather than raw pointers. In Rust, this is the standard way: you don't use *mut raw pointers unless you're talking to C. This book chapter has a lot of details on references: References and Borrowing - The Rust Programming Language