Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
Development dependencies Sometimes there is a need to have dependencies for tests (or examples, or benchmarks) only. Such dependencies are added to Cargo.toml in the [dev-dependencies] section. These dependencies are not propagated to other...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Unsafe Operations As an introduction to this section, to borrow from the official docs, "one should try to minimize the amount of unsafe code in a code base." With that in mind, let's get started! Unsafe annotations in Rust are used to bypa...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Inline assembly Rust provides support for inline assembly via the asm! macro. It can be used to embed handwritten assembly in the assembly output generated by the compiler. Generally this should not be necessary, but might be where the requ...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~15 min read
Compatibility The Rust language is evolving rapidly, and because of this certain compatibility issues can arise, despite efforts to ensure forwards-compatibility wherever possible. • Raw identifiers
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Raw identifiers Rust, like many programming languages, has the concept of "keywords". These identifiers mean something to the language, and so you cannot use them in places like variable names, function names, and other places. Raw identifi...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Meta Some topics aren't exactly relevant to how your program runs but provide you tooling or infrastructure support which just makes things better for everyone. These topics include: • Documentation: Generate library documentation for users...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Documentation Use cargo doc to build documentation in target/doc, cargo doc --open will automatically open it in your web browser. Use cargo test to run all tests (including documentation tests), and cargo test --doc to only run documentati...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~2 min read
Playground The Rust Playground is a way to experiment with Rust code through a web interface. Using it with mdbook In mdbook, you can make code examples playable and editable. fn main() { println!("Hello World!"); } This allows the reader t...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
The Rustonomicon Warning: This book is incomplete. Documenting everything and rewriting outdated parts take a while. See the issue tracker to check what's missing/outdated, and if there are any mistakes or ideas that haven't been reported,...
doc.rust-lang.org The Rustonomicon Book 2024-01-01 ~2 min read
Meet Safe and Unsafe safe and unsafe It would be great to not have to worry about low-level implementation details. Who could possibly care how much space the empty tuple occupies? Sadly, it sometimes matters and we need to worry about it....
doc.rust-lang.org The Rustonomicon Book 2024-01-01 ~2 min read
How Safe and Unsafe Interact What's the relationship between Safe Rust and Unsafe Rust? How do they interact? The separation between Safe Rust and Unsafe Rust is controlled with the unsafe keyword, which acts as an interface from one to the...
doc.rust-lang.org The Rustonomicon Book 2024-01-01 ~6 min read
What Unsafe Rust Can Do The only things that are different in Unsafe Rust are that you can: • Dereference raw pointers • Call unsafe functions (including C functions, compiler intrinsics, and the raw allocator) • Implement unsafe traits • A...
doc.rust-lang.org The Rustonomicon Book 2024-01-01 ~3 min read
Working with Unsafe Rust generally only gives us the tools to talk about Unsafe Rust in a scoped and binary manner. Unfortunately, reality is significantly more complicated than that. For instance, consider the following toy function: fn in...
doc.rust-lang.org The Rustonomicon Book 2024-01-01 ~3 min read
Data Representation in Rust Low-level programming cares a lot about data layout. It's a big deal. It also pervasively influences the rest of the language, so we're going to start by digging into how data is represented in Rust. This chapter...
doc.rust-lang.org The Rustonomicon Book 2024-01-01 ~1 min read
repr(Rust) First and foremost, all types have an alignment specified in bytes. The alignment of a type specifies what addresses are valid to store the value at. A value with alignment n must only be stored at an address that is a multiple o...
doc.rust-lang.org The Rustonomicon Book 2024-01-01 ~4 min read
Exotically Sized Types Most of the time, we expect types to have a statically known and positive size. This isn't always the case in Rust. Dynamically Sized Types (DSTs) Rust supports Dynamically Sized Types (DSTs): types without a statical...
doc.rust-lang.org The Rustonomicon Book 2024-01-01 ~5 min read
Alternative representations Rust allows you to specify alternative data layout strategies from the default. repr(C) This is the most important repr. It has fairly simple intent: do what C does. The order, size, and alignment of fields is ex...
doc.rust-lang.org The Rustonomicon Book 2024-01-01 ~6 min read
Ownership and Lifetimes Ownership is the breakout feature of Rust. It allows Rust to be completely memory-safe and efficient, while avoiding garbage collection. Before getting into the ownership system in detail, we will consider the motiva...
doc.rust-lang.org The Rustonomicon Book 2024-01-01 ~2 min read
References There are two kinds of references: • Shared reference: & • Mutable reference: &mut Which obey the following rules: • A reference cannot outlive its referent • A mutable reference cannot be aliased That's it. That's the whole mode...
doc.rust-lang.org The Rustonomicon Book 2024-01-01 ~1 min read
Aliasing First off, let's get some important caveats out of the way: • We will be using the broadest possible definition of aliasing for the sake of discussion. Rust's definition will probably be more restricted to factor in mutations and l...
doc.rust-lang.org The Rustonomicon Book 2024-01-01 ~4 min read
"Will never stop being positively surprised by clippy ```text error: hypothenuse can be computed more accurately: --> src/main.rs:835:5 | 835 | (w..."

Search tips

Type anything to search across articles, videos (including conference talks), podcasts, and research. These operators give you finer control — click an example to try it.

Find pages containing all your words. Pages where the words appear together rank higher.
Quote part of your query to keep those words together as an exact phrase within a larger search.
Wrap the whole query in quotes for a verbatim search that matches text exactly, punctuation and all — perfect for Rust syntax. Needs at least 3 characters.
Limit results to a single site. Works on its own () too. One site: per search.

Use the tabs and filters above the results to narrow by content type, publication year, and sort order.