Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Integration testing Unit tests are testing one module in isolation at a time: they're small and can test private code. Integration tests are external to your crate and use only its public interface in the same way any other code would. Thei...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Documentation testing The primary way of documenting a Rust project is through annotating the source code. Documentation comments are written in CommonMark Markdown specification and support code blocks in them. Rust takes care about correc...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~2 min read
Unit testing Tests are Rust functions that verify that the non-test code is functioning in the expected manner. The bodies of test functions typically perform some setup, run the code we want to test, then assert whether the results are wha...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~4 min read
"I performed an extremely scientific poll on twitter, and determined this is not how it's pronounced ---- Well, it really is `Vec<T, A>`, pronounced ..."

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.