Closed
Description
Some C libraries want you to create a structure on the stack and pass it off to be initialized by some function. Right now the typestate requires all structures to be fully defined before being passed to a function, so I'm finding myself having to write:
type foo_t = { p: *ctypes::void, i: ctypes::c_int };
native mod foo {
fn f(foo: foo_t);
}
fn bar() {
let x = { p: ptr::null(), i: 0 as ctypes::c_int };
foo::f(x);
...
}
Since I'm passing raw pointers to c, it's naturally unsafe, so it'd be nice if we could allow foo_t
to be opaque to the typestate system. What if we allow native module functions to have a flag saying they can initialize an uninitialized value? It'd help simplify binding to third party libraries.