Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
doc.rust-lang.org
pub fn connect_addr(socket_addr: &SocketAddr) -> io::Result<UnixStream>
...Examples use std::os::unix::net::{UnixListener, UnixStream}; fn main() -> std::io::Result<()> { let listener = UnixListener::bind("/path/to/the/socket")?; let addr = listener.local_addr()?; let sock = match UnixStream::connect_addr(&addr) { Ok(sock) => sock, Err(e) => { println!("Couldn't connect: {e:?}"); return Err(e) } }; Ok(()) }
associated_function std Stable since 1.70.0 Version 1.100.0-nightly
arzg.github.io
...Option<ast::Expr>) -> Expr { if let Some(ast) = ast { match ast { // snip ast::Expr::VariableRef(ast) => Expr::VariableRef { var: ast.name().unwrap().text().into(), }, } } else { // snip } } // snip } That match arm is longer than one line; let’s extract it to a method for consistency:impl Database { // snip pub(crate) fn...
Rust Walkthroughs 2021-01-27 ~18 min read
ryan-jacobs1.github.io
...fn cleanup() { let me = smp::me(); let mut cleanup_work = CLEANUP[me].lock(); loop { match cleanup_work.get_task() { Some(work) => {work()}, None => {break} } } } Now we can finish our implementation of surrender and move on to block: pub fn surrender() { let mut current_thread: Box<dyn TCB> = match swap_active...
News & Blog Posts 2020-01-14 ~9 min read
www.youtube.com
...be totally valid to have like some other kind of decal to have two non-terminals that both match to the same set of things and when you do the pattern matching you couldn't really tell the difference between whether something was originally a trait impuldecal and you just...
Video 2022-04-20
blog.turbo.fish
...Figuring out what's inside is a simple manner of matching: use syn::{Data, DataStruct, Fields}; let fields = match input.data { Data::Struct(DataStruct { fields: Fields::Named(fields), .. }) => fields.named, _ => panic!("this derive macro only works on structs with named fields"), }; Here, we panic!() if the input is not what...
Rust Walkthroughs 2021-02-24 ~12 min read
docs.rs
...Install [dependencies] diff = "0.1" Example extern crate diff; fn main() { let left = "foo\nbar\nbaz\nquux"; let right = "foo\nbaz\nbar\nquux"; for diff in diff::lines(left, right) { match diff { diff::Result::Left(l) => println!("-{}", l), diff::Result::Both(l, _) => println!(" {}", l), diff::Result::Right(r) => println!("+{}", r...
Crate v0.1.13 2022-06-29
doc.rust-lang.org
pub fn bind_addr(socket_addr: &SocketAddr) -> io::Result<UnixDatagram>
...Examples use std::os::unix::net::{UnixDatagram}; fn main() -> std::io::Result<()> { let sock1 = UnixDatagram::bind("path/to/socket")?; let addr = sock1.local_addr()?; let sock2 = match UnixDatagram::bind_addr(&addr) { Ok(sock) => sock, Err(err) => { println!("Couldn't bind: {err:?}"); return Err(err); } }; Ok(()) }
associated_function std Stable since 1.70.0 Version 1.100.0-nightly
rust-analyzer.github.io
...Your browser does not support the video tag. #12345 (first contribution) add escapeSequence semantic token type. #12263 hide type inlay hints for let statements that initialize a closure (enable using rust-analyzer.inlayHints.typeHints.hideClosureInitialization): #12130 add assist to turn let-else statements into let and match: Your browser does...
Project/Tooling Updates 2022-05-25 ~1 min read
doc.rust-lang.org
pub fn ends_with<P>(&self, child: P) -> bool
...Only considers whole path components to match. Examples use std::path::Path; let path = Path::new("/etc/resolv.conf"); assert!(path.ends_with("resolv.conf")); assert!(path.ends_with("etc/resolv.conf")); assert!(path.ends_with("/etc/resolv.conf")); assert!(!path.ends_with("/resolv.conf")); assert!(!path.ends_with("conf...
method std Stable since 1.0.0 Version 1.100.0-nightly
brson.github.io
...Linked error-chain errors are able to propagate backtraces and have a structural shape that is easy to deeply match, so that e.g. your error that originated in your utils crate, bubbled through your net crate, then up through your app crate is easy to pinpoint through pattern matching...
News & Blog Posts 2016-12-06 ~6 min read
rust-lang.github.io
...Since we already allow recursion via const fn and termination of said recursion via if or match, all code enabled by const recursion is already legal now. Some algorithms are better expressed as imperative loops and a lot of Rust code uses loops instead of recursion. Allowing loops in constants...
RFC 2344 RFC 2018-02-18 ~2 min read
rust-analyzer.github.io
#3084 better error reporting around workspace loading. #3102 better error reporting when deserializing wrong config. #3092 fix error when starting the server immediately after download. #3100 improved error handling when downloading the server binary. #3114 fix type inference for match arms of unknown type. #3121 during auto-import, don’t...
News & Blog Posts 2020-02-18 ~1 min read
arXiv arxiv.org
...Its scalability for these tasks matches or exceeds that of leading Datalog systems. We demonstrate uses in reasoning with knowledge graphs and ontologies with 10^5 to 10^8 input facts, all on a laptop. Nemo is written in Rust and available as a free and open source tool.
Artificial Intelligence Alex Ivliev, Stefan Ellmauthaler, Lukas Gerlach et al. 2023-08-30 arXiv:2308.15897
doc.rust-lang.org
pub fn back_mut(&mut self) -> Option<&mut T>
...Examples use std::collections::VecDeque; let mut d = VecDeque::new(); assert_eq!(d.back(), None); d.push_back(1); d.push_back(2); match d.back_mut() { Some(x) => *x = 9, None => (), } assert_eq!(d.back(), Some(&9));
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub const fn iter_mut(&mut self) -> IterMut<'_, T>
...Result<u32, &str> = Ok(7); match x.iter_mut().next() { Some(v) => *v = 40, None => {}, } assert_eq!(x, Ok(40)); let mut x: Result<u32, &str> = Err("nothing!"); 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 Incoming<'a>
...UnixStream) { // ... } fn main() -> std::io::Result<()> { let listener = UnixListener::bind("/path/to/the/socket")?; for stream in listener.incoming() { match stream { Ok(stream) => { thread::spawn(|| handle_client(stream)); } Err(err) => { break; } } } Ok(()) }
struct std Stable since 1.10.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn bind_addr(socket_addr: &SocketAddr) -> io::Result<UnixListener>
...Examples use std::os::unix::net::{UnixListener}; fn main() -> std::io::Result<()> { let listener1 = UnixListener::bind("path/to/socket")?; let addr = listener1.local_addr()?; let listener2 = match UnixListener::bind_addr(&addr) { Ok(sock) => sock, Err(err) => { println!("Couldn't bind: {err:?}"); return Err(err); } }; Ok(()) }
associated_function std Stable since 1.70.0 Version 1.100.0-nightly
nikolish.in
...Self::Message) { match message { CounterMessage::Increment => self.count += 1, CounterMessage::Decrement => self.count -= 1, CounterMessage::ChangePage(view) => self.current_view = view }} We simple update the state of our application by assigning the current_view with the view that is passed by the message. We now need to somehow produce this...
Observations/Thoughts 2022-06-22 ~7 min read
doc.rust-lang.org
pub fn front_mut(&mut self) -> Option<&mut T>
...Examples use std::collections::VecDeque; let mut d = VecDeque::new(); assert_eq!(d.front_mut(), None); d.push_back(1); d.push_back(2); match d.front_mut() { Some(x) => *x = 9, None => (), } assert_eq!(d.front(), Some(&9));
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn incoming(&self) -> Incoming<'_>
...UnixStream) { // ... } fn main() -> std::io::Result<()> { let listener = UnixListener::bind("/path/to/the/socket")?; for stream in listener.incoming() { match stream { Ok(stream) => { thread::spawn(|| handle_client(stream)); } Err(err) => { break; } } } Ok(()) }
method std Stable since 1.10.0 Version 1.100.0-nightly
"apparently I wrote Building Git to explain a complex problem to rust devs who could then help me build it in rust"

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.
Put ! first to open the top result immediately. Quote the whole query for a literal leading bang, as in '!Send'. Bangs elsewhere, such as println!, stay literal. Browser and launcher shortcuts can invoke this directly. See search integrations.
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.