Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
Std misc Many other types are provided by the std library to support things such as: • Threads • Channels • File I/O These expand beyond what the primitives provide. See also: primitives and the std library
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Threads Rust provides a mechanism for spawning native OS threads via the spawn function, the argument of this function is a moving closure. use std::thread; const NTHREADS: u32 = 10; // This is the `main` thread fn main() { // Make a vector...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Testcase: map-reduce Rust makes it very easy to parallelize data processing, without many of the headaches traditionally associated with such an attempt. The standard library provides great threading primitives out of the box. These, combin...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~3 min read
Channels Rust provides asynchronous channels for communication between threads. Channels allow a unidirectional flow of information between two end-points: the Sender and the Receiver. use std::sync::mpsc::{Sender, Receiver}; use std::sync:...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Path The Path type represents file paths in the underlying filesystem. Across all platforms there is a single std::path::Path that abstracts over platform-specific path semantics and separators. Bring it into scope with use std::path::Path;...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
File I/O The File struct represents a file that has been opened (it wraps a file descriptor), and gives read and/or write access to the underlying file. Since many things can go wrong when doing file I/O, all the File methods return the io:...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
open The open function can be used to open a file in read-only mode. A File owns a resource, the file descriptor and takes care of closing the file when it is droped. use std::fs::File; use std::io::prelude::*; use std::path::Path; fn main(...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
create The create function opens a file in write-only mode. If the file already existed, the old content is destroyed. Otherwise, a new file is created. static LOREM_IPSUM: &str = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, s...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
read_lines A naive approach This might be a reasonable first attempt for a beginner's first implementation for reading lines from a file. use std::fs::read_to_string; fn read_lines(filename: &str) -> Vec<String> { let mut result = Vec::new(...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Child processes The process::Output struct represents the output of a finished child process, and the process::Command struct is a process builder. use std::process::Command; fn main() { let output = Command::new("rustc") .arg("--version")...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Pipes The std::process::Child struct represents a child process, and exposes the stdin, stdout and stderr handles for interaction with the underlying process via pipes. use std::io::prelude::*; use std::process::{Command, Stdio}; static PAN...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Wait If you'd like to wait for a process::Child to finish, you must call Child::wait, which will return a process::ExitStatus. use std::process::Command; fn main() { let mut child = Command::new("sleep").arg("5").spawn().unwrap(); let _resu...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Filesystem Operations The std::fs module contains several functions that deal with the filesystem. use std::fs; use std::fs::{File, OpenOptions}; use std::io; use std::io::prelude::*; #[cfg(target_family = "unix")] use std::os::unix; #[cfg(...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~2 min read
Program arguments Standard Library The command line arguments can be accessed using std::env::args, which returns an iterator that yields a String for each argument: use std::env; fn main() { let args: Vec<String> = env::args().collect(); /...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Argument parsing Matching can be used to parse simple arguments: use std::env; fn increase(number: i32) { println!("{}", number + 1); } fn decrease(number: i32) { println!("{}", number - 1); } fn help() { println!("usage: match_args <string...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Foreign Function Interface Rust provides a Foreign Function Interface (FFI) to C libraries. Foreign functions must be declared inside an extern block annotated with a #[link] attribute containing the name of the foreign library. use std::fm...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 min read
Testing Rust is a programming language that cares a lot about correctness and it includes support for writing software tests within the language itself. Testing comes in three styles: • Unit testing. • Doc testing. • Integration testing. Al...
doc.rust-lang.org Rust by Example Book 2024-01-01 ~1 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
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
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
"protip: the rust extern keyword has a --help flag ```text error[E0703]: invalid ABI: found `--help` --> ext.rs:1:8 | 1 | extern "--help" {} fn main(..."

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.