github.com
...let mut current_op = Op::Plus; let mut current_digit = 0; for d in op_or_digit.into_iter() { match d { OpOrDigit::Op(op) => { current_op = op }, OpOrDigit::Digit(n) => { match current_op { Op::Plus => { current_digit += n }, Op::Minus => { current_digit -= n }, Op::Multiply => { current_digit *= n }, } }, } } assert_eq...
Crate
v0.12.0
2023-11-18
docs.rs
Diff library with semantic cleanup, based on Google's diff-match-patch
Crate
v1.0.11
2026-03-15
docs.rs
...loop { for issue in &page { println!("{}", issue.title); } page = match octocrab .get_page::<models::issues::Issue>(&page.next) .await? { Some(next_page) => next_page, None => break, } } HTTP API The typed API currently doesn't cover all of GitHub's API at this time, and even if it did GitHub is...
Crate
v0.54.1
2026-07-24
docs.rs
...Some things wouldn't ever be written on one line, like this match expression, and certainly not with a comma in front of the closing brace: fn eq(&self, other: &IpAddr) -> bool { match other { IpAddr::V4(v4) => self == v4, IpAddr::V6(_) => false, } } Some places use non-multiple-of-4 indentation...
Crate
v0.3.0
2026-07-18
crates.io
Emulate macro-rules pattern matching in procedural macros proc-macro-rules macros You are probably looking for the proc-macro-rules crate.
Crate
v0.4.0
2023-11-07
docs.rs
...extern crate version_check as rustc; match rustc::is_min_date("2018-12-18") { Some(true) => "Yep! It's recent!", Some(false) => "No, it's older.", None => "Couldn't determine the rustc version." }; Check that the running compiler supports feature flags: extern crate version_check as rustc; match rustc::is...
Crate
v0.9.5
2024-07-25
docs.rs
...Here's a simple example that matches a date in YYYY-MM-DD format and prints the year, month and day: use regex_lite::Regex; fn main() { let re = Regex::new(r"(?x) (?P<year>\d{4}) # the year - (?P<month>\d{2}) # the month - (?P<day>\d{2}) # the...
Crate
v0.1.9
2026-02-03
crates.io
...let parser = parser.map(|event| match event { Event::SoftBreak => Event::HardBreak, _ => event }); Or expanding an abbreviation in text: let parser = parser.map(|event| match event { Event::Text(text) => Event::Text(text.replace("abbr", "abbreviation").into()), _ => event }); Another simple example is code to determine the max nesting level: let mut max...
Crate
v0.13.4
2026-05-20
crates.io
GraphQL introspection query and response types. graphql-introspection-query This crate defines structs implementing serde::Deserialize that match the shape returned by a spec-compliant GraphQL API presented with the introspection query.
Crate
v0.3.0
2025-12-08
github.com
...0.3.8 Tracking upstream to match version 0.7.1 Recommended to upgrade from 0.3.7 to get an important bug fix. 0.3.7 Tracking upstream to match version 0.7 0.3.4 Tracking upstream to version 0.6.2. 0.3.3 Tracking upstream to...
Crate
v0.7.5
2026-08-12
docs.rs
...Click, click, click!", termion::clear::All, termion::cursor::Goto(1, 1)).unwrap(); stdout.flush().unwrap(); for c in stdin.events() { let evt = c.unwrap(); match evt { Event::Key(Key::Char('q')) => break, Event::Mouse(me) => { match me { MouseEvent::Press(_, x, y) => { write!(stdout, "{}x", termion::cursor::Goto(x, y)).unwrap...
Crate
v4.0.6
2025-11-21
sentry.io
...use sentry::integrations::tracing::EventFilter; use tracing_subscriber::prelude::*; let sentry_layer = sentry::integrations::tracing::layer() .event_filter(|md| match *md.level() { tracing::Level::ERROR => EventFilter::Event, _ => EventFilter::Ignore, }) .span_filter(|md| matches!(*md.level(), tracing::Level::ERROR | tracing::Level::WARN)); tracing_subscriber::registry() .with(tracing_subscriber::fmt::layer()) .with...
Crate
v0.49.1
2026-08-03
docs.rs
The tree-sitter Language type, used by the library and by language implementations Tree-sitter Language This crate provides a LanguageFn type for grammars to create Language instances from a parser, without having to worry about the tree-sitter crate version not matching.
Crate
v0.1.7
2026-02-01
docs.babelmonkeys.de
...use xml::{Event, Parser}; // Create a new Parser let mut p = Parser::new(); // Feed data to be parsed p.feed_str("<a href"); p.feed_str("='//example.com'/>"); // Get events for the fed data for event in p { match event.unwrap() { Event::ElementStart(tag) => println!("<{}>", tag.name), Event::ElementEnd(tag...
Crate
v0.3.0
2020-03-08
docs.rs
...Originally intended to be a way to just parse the semver spec into data structures, with no logic around matching and such, this functionality now lives in the semver crate, and therefore, is no longer used.
Crate
v0.10.3
2024-11-18
docs.rs
...TomlError { message: "data did not match any variant of untagged enum Ohno", original: Some("\ninteger = 42\nstring = \"we want this to be spanned\"\n"), keys: ["string"], span: Some(23..51) } } } To understand why this fails we can look at what #[derive(serde::Deserialize)] expand to for Ohno in HIR. #[allow...
Crate
v0.7.1
2026-03-06
crates.io
...Vec<OsString>) -> windows_service::Result<()> { let event_handler = move |control_event| -> ServiceControlHandlerResult { match control_event { ServiceControl::Stop | ServiceControl::Interrogate => { ServiceControlHandlerResult::NoError } _ => ServiceControlHandlerResult::NotImplemented, } }; // Register system service event handler let status_handle = service_control_handler::register("my_service_name", event_handler)?; let next_status = ServiceStatus { // Should match the one from system...
Crate
v0.8.1
2026-05-08
docs.rs
...It offers means to match your type's signature - <T as zvariant::Type>::signature() - with a corresponding signature retrieved from a DBus XML file. This way zbus-lockstep prevents definitions from drifting apart. Motivation In the context of IPC over DBus - especially when there are multiple implementations of servers and...
Crate
v0.7.0
2026-07-27
crates.io
...u32) -> u32 { match n { 1 | 2 => 1, _ => fibonacci_native(n - 1) + fibonacci_native(n - 2), } } #[napi] fn get_cwd<T: Fn(String) -> Result<()>>(callback: T) { callback(env::current_dir().unwrap().to_string_lossy().to_string()).unwrap(); }
Crate
v3.6.3
2026-08-10
docs.rs
...ListTablesInput = Default::default(); match client.list_tables(list_tables_input).await { Ok(output) => match output.table_names { Some(table_name_list) => { println!("Tables in database:"); for table_name in table_name_list { println!("{}", table_name); } } None => println!("No tables in database!"), }, Err(error) => { println!("Error: {:?}", error); } } } Usage with rustls If...
Crate
v0.48.0
2022-04-25