Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
doc.rust-lang.org
pub fn offset(&self) -> usize
...This means that, when the iterator has not been fully consumed, the returned value will match the index that will be returned by the next call to next(). Examples let mut chars = "a楽".char_indices(); // `next()` has not been called yet, so `offset()` returns the byte // index of the first...
method core Stable since 1.82.0 Version 1.100.0-nightly
doc.rust-lang.org
primitive bool
...or, a match pattern match praise_the_borrow_checker { true => println!("keep praising!"), false => println!("you should praise!"), } Also, since bool implements the Copy trait, we don't have to worry about the move semantics (just like the integer and float primitives). Now an example of bool cast to integer...
primitive core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
primitive bool
...or, a match pattern match praise_the_borrow_checker { true => println!("keep praising!"), false => println!("you should praise!"), } Also, since bool implements the Copy trait, we don't have to worry about the move semantics (just like the integer and float primitives). Now an example of bool cast to integer...
primitive std Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn chars(&self) -> Chars<'_>
...It's important to remember that char represents a Unicode Scalar Value, and might not match your idea of what a 'character' is. Iteration over grapheme clusters may be what you actually want. This functionality is not provided by Rust's standard library, check crates.io instead. Examples Basic usage...
method core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
fn position<P>(&mut self, predicate: P) -> Option<usize>
...Overflow Behavior The method does no guarding against overflows, so if there are more than usize::MAX non-matching elements, it either produces the wrong result or panics. If overflow checks are enabled, a panic is guaranteed. Panics This function might panic if the iterator has more than usize::MAX...
method core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub const fn extend(&self, next: Self) -> Result<(Self, usize), LayoutError>
...In order to match C representation layout repr(C), you should call pad_to_align after extending the layout with all fields. (There is no way to match the default Rust representation layout repr(Rust), as it is unspecified.) Note that the alignment of the resulting layout will be the...
method core Stable since 1.44.0 Version 1.100.0-nightly
doc.rust-lang.org
pub trait IndexMut<Idx>
...Side) -> &Self::Output { println!("Accessing {index:?}-side of balance immutably"); match index { Side::Left => &self.left, Side::Right => &self.right, } } } impl IndexMut<Side> for Balance { fn index_mut(&mut self, index: Side) -> &mut Self::Output { println!("Accessing {index:?}-side of balance mutably"); match index { Side::Left => &mut self.left, Side...
trait core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn current_exe() -> io::Result<crate::path::PathBuf>
...For example, on some Unix platforms, the result is calculated by searching $PATH for an executable matching argv[0], but both the environment and arguments can be be set arbitrarily by the user who invokes the program. On Linux, if fs.secure_hardlinks is not set, an attacker who can...
function std Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub enum Cow<'a, B>
...v } } } // Creates a container from borrowed values of a slice let readonly = [1, 2]; let borrowed = Items::new((&readonly[..]).into()); match borrowed { Items { values: Cow::Borrowed(b) } => println!("borrowed {b:?}"), _ => panic!("expect borrowed value"), } let mut clone_on_write = borrowed; // Mutates the data from slice into owned vec and pushes...
enum alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn swap<T>(x: *mut T, y: *mut T)
...to them be `[2, 3]`, so that indices `0..3` are // `[1, 2, 3]` (matching `y` before the `swap`); or for them to be `[0, 1]` // so that indices `1..4` are `[0, 1, 2]` (matching `x` before the `swap`). // This implementation is defined to make the latter choice. assert...
function core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub const fn as_mut(&mut self) -> Option<&mut T>
Option::as_mut — Converts from &mut Option<T> to Option<&mut T>. Examples let mut x = Some(2); match x.as_mut() { Some(v) => *v = 42, None => {}, } assert_eq!(x, Some(42));
method core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn connect<P>(path: P) -> io::Result<UnixStream>
UnixStream::connect — Connects to the socket named by path. Examples use std::os::unix::net::UnixStream; let socket = match UnixStream::connect("/tmp/sock") { Ok(sock) => sock, Err(e) => { println!("Couldn't connect: {e:?}"); return } };
associated_function std Stable since 1.10.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn unbound() -> io::Result<UnixDatagram>
UnixDatagram::unbound — Creates a Unix Datagram socket which is not bound to any address. Examples use std::os::unix::net::UnixDatagram; let sock = match UnixDatagram::unbound() { Ok(sock) => sock, Err(e) => { println!("Couldn't unbound: {e:?}"); return } };
associated_function std Stable since 1.10.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn bind<P>(path: P) -> io::Result<UnixListener>
UnixListener::bind — Creates a new UnixListener bound to the specified socket. Examples use std::os::unix::net::UnixListener; let listener = match UnixListener::bind("/path/to/the/socket") { Ok(sock) => sock, Err(e) => { println!("Couldn't connect: {e:?}"); return } };
associated_function std Stable since 1.10.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn bind<P>(path: P) -> io::Result<UnixDatagram>
UnixDatagram::bind — Creates a Unix datagram socket bound to the given path. Examples use std::os::unix::net::UnixDatagram; let sock = match UnixDatagram::bind("/path/to/the/socket") { Ok(sock) => sock, Err(e) => { println!("Couldn't bind: {e:?}"); return } };
associated_function std Stable since 1.10.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn pair() -> io::Result<(UnixDatagram, UnixDatagram)>
UnixDatagram::pair — Creates an unnamed pair of connected sockets. Returns two UnixDatagramss which are connected to each other. Examples use std::os::unix::net::UnixDatagram; let (sock1, sock2) = match UnixDatagram::pair() { Ok((sock1, sock2)) => (sock1, sock2), Err(e) => { println!("Couldn't unbound: {e:?}"); return } };
associated_function std Stable since 1.10.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn iter_mut(&mut self) -> IterMut<'_, T>
Option::iter_mut — Returns a mutable iterator over the possibly contained value. Examples let mut x = Some(4); match x.iter_mut().next() { Some(v) => *v = 42, None => {}, } assert_eq!(x, Some(42)); let mut x: Option<u32> = None; assert_eq!(x.iter_mut().next(), None);
method core Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub struct SocketAddr
SocketAddr — An address associated with a Unix socket. Examples use std::os::unix::net::UnixListener; let socket = match UnixListener::bind("/tmp/sock") { Ok(sock) => sock, Err(e) => { println!("Couldn't bind: {e:?}"); return } }; let addr = socket.local_addr().expect("Couldn't get local address");
struct std Stable since 1.10.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn pair() -> io::Result<(UnixStream, UnixStream)>
UnixStream::pair — Creates an unnamed pair of connected sockets. Returns two UnixStreams which are connected to each other. Examples use std::os::unix::net::UnixStream; let (sock1, sock2) = match UnixStream::pair() { Ok((sock1, sock2)) => (sock1, sock2), Err(e) => { println!("Couldn't create a pair of sockets: {e:?}"); return } };
associated_function std Stable since 1.10.0 Version 1.100.0-nightly
doc.rust-lang.org
pub mod ffi
...This module provides types which will match those defined by C, so that code that interacts with C will refer to the correct types.
module core Stable since 1.30.0 Version 1.100.0-nightly
"The whole point of Rust is that before there were two worlds: * Inefficient, garbage collected, reliable languages * Efficient, manually allocated, d..."
— Simon Buchan on rust-users

Search tips

Type anything to search across articles, videos (including conference talks), podcasts, research, crates, and Rust API documentation. 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.