Extern type

From Rust Community Wiki

Note: This is a nightly-only feature.

  • See types|[_ |-}}.html RFC 1861: extern types]
  • Enable on nightly with #![feature(extern_types)]

An extern type is a type which the compiler knows nothing about. It might be dynamically sized or have a fixed size, but either way the compiler doesn't know the size. The main purpose of extern types is interoperability with other languages, e.g. C; it is equivalent to a void pointer (void *) in C.

Like DSTs, extern types must be behind a reference or a pointer-like type, such as BoxThis links to official Rust documentation. Unlike a DST, a reference/pointer to an extern type is a regular (thin) pointer, not a fat pointer.

Example[edit]

#![feature(extern_types)]

extern {
    type Foo;
}

extern "C" fn foo(_: *const Foo) {}