ffi.rs.html -- source
Description: Source to the Rust file `libcore/ffi.rs`.
Keywords: rust, rustlang, rust-lang

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42

    #![stable(feature = "", since = "1.30.0")]

    #![allow(non_camel_case_types)]

    //! Utilities related to FFI bindings.

    use ::fmt;

    /// Equivalent to C's `void` type when used as a [pointer].
    ///
    /// In essence, `*const c_void` is equivalent to C's `const void*`
    /// and `*mut c_void` is equivalent to C's `void*`. That said, this is
    /// *not* the same as C's `void` return type, which is Rust's `()` type.
    ///
    /// Ideally, this type would be equivalent to [`!`], but currently it may
    /// be more ideal to use `c_void` for FFI purposes.
    ///
    /// [`!`]: ../../std/primitive.never.html
    /// [pointer]: ../../std/primitive.pointer.html
    // NB: For LLVM to recognize the void pointer type and by extension
    //     functions like malloc(), we need to have it represented as i8* in
    //     LLVM bitcode. The enum used here ensures this and prevents misuse
    //     of the "raw" type by only having private variants.. We need two
    //     variants, because the compiler complains about the repr attribute
    //     otherwise.
    #[repr(u8)]
    #[stable(feature = "raw_os", since = "1.1.0")]
    pub enum c_void {
        #[unstable(feature = "c_void_variant", reason = "should not have to exist",
                   issue = "0")]
        #[doc(hidden)] __variant1,
        #[unstable(feature = "c_void_variant", reason = "should not have to exist",
                   issue = "0")]
        #[doc(hidden)] __variant2,
    }

    #[stable(feature = "std_debug", since = "1.16.0")]
    impl fmt::Debug for c_void {
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
            f.pad("c_void")
        }
    }

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)