Closed
Description
As in
let ptr = match mmap(...) {
-1 as *mut c_void => panic!(),
p => p,
}
This is very useful for FFI and #![no_std]
, I don't think it takes anything away, and it shouldn't be too difficult to add.
Possibilities right now include
let ptr = match mmap(...) as usize {
-1 => panic!(),
p => p as *mut c_void,
}
or
let ptr = match mmap(...) {
p if p == -1 => panic!(),
p => p,
}
Another possible idea, one that I doubt many people would like, is to allow *const
and *mut
pointers to be integrals. Then you could just do the C thing of
let ptr = match mmap(...) {
-1 => panic!(), // -1 is a *mut c_void in this situation
p => p,
}