crate - Rust
Description: API documentation for the Rust `crate` keyword in crate `std`.
Keywords: rust, rustlang, rust-lang, crate

# [−]Keyword crate

The `crate` keyword.

The primary use of the `crate` keyword is as a part of `extern crate` declarations, which are used to specify a dependency on a crate external to the one it's declared in. Crates are the fundamental compilation unit of Rust code, and can be seen as libraries or projects. More can be read about crates in the Reference.

ⓘThis example is not tested

    extern crate rand;
    extern crate my_crate as thing;
    extern crate std; // implicitly added to the root of every Rust projectRun

The `as` keyword can be used to change what the crate is referred to as in your project. If a crate name includes a dash, it is implicitly imported with the dashes replaced by underscores.

`crate` is also used as in conjunction with `pub` to signify that the item it's attached to is public only to other members of the same crate it's in.

    pub(crate) use std::io::Error as IoError;
    pub(crate) enum CoolMarkerType { }
    pub struct PublicThing {
        pub(crate) semi_secret_thing: bool,
    }Run

# 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`)