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.2
2026-10-02
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
...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
...Test pattern matches: assert!(let Err(e) = File::open("/non/existing/file")) . Use let chains (even with compilers older than Rust 1.88). See which part of a && chain failed. Re-use captured variables from pattern matches in later code with assert!(...) . Perform multiple checks before panicking with check!(...) . Colored...
Crate
v0.4.1
2026-09-09
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.8.0
2026-11-16
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.7.2
2026-11-23
docs.rs
...this is the generic case when we don't know about the input BufRead. // when the input is a &str or a &[u8], we don't actually need to use another // buffer, we could directly call `reader.read_event()` match reader.read_event_into(&mut buf) { Err(e) => panic!("Error...
Crate
v0.42.0
2026-08-22
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
docs.rs
...The API version for the given message matching the version specified in the request header must be provided. use bytes::BytesMut; use kafka_protocol::messages::MetadataRequest; use kafka_protocol::protocol::Encodable; let mut bytes = BytesMut::new(); let request = MetadataRequest::default(); request.encode(&mut bytes, 12).unwrap(); Deserialization Messages can be...
Crate
v0.18.0
2026-08-20
crates.io
...This allows us to write custom preconditions for matching code. Let's make this more clear with a concrete example. Here is the declaration of an external extractor to match on the high-level instruction that defined a given operand Value , along with a new rule to sink loads into...
Crate
v0.138.0
2026-11-20
docs.rs
...cannot move out of borrowed content *self = match *self { // ^^^^^ cannot move out of borrowed content States::A(a) => States::B(a), States::B(a) => States::A(a), }; } } Depending on context this can be quite tricky to work around. With this crate, however: enum States { A(String), B(String), } impl States...
Crate
v0.1.8
2025-05-20
neosmart.net
...ignore-result for rust Safely ignore errors in function return values when the result isn't critical This crate adds a .ignore() function to Result instances that ignores both the Ok and Err variants of the result, silencing compiler warnings about unused errors without needing to resort to empty match...
Crate
v0.2.0
2018-12-24
crates.io
...Linux, Windows, MacOS, FreeBSD, OpenBSD, illumos Example use mac_address::get_mac_address; fn main() { match get_mac_address() { Ok(Some(ma)) => { println!("MAC addr = {}", ma); println!("bytes = {:?}", ma.bytes()); } Ok(None) => println!("No MAC address found."), Err(e) => println!("{:?}", e), } } License mac_address is licensed under both MIT and...
Crate
v1.2.1
2026-10-11
docs.rs
Prefix trie (tree) datastructure (both a set and a map) that provides exact and longest-prefix matches. Prefix-Trie This crate provides prefix-map and prefix-set collections for IP prefixes and other fixed-width prefix types. PrefixMap is backed by a compact TreeBitMap-style trie and supports exact, longest...
Crate
v0.10.2
2026-11-04
docs.rs
...extern crate http_range; use http_range::{HttpRange}; fn main() { let range_str = "bytes=0-8"; let size = 10; match HttpRange::parse(range_str, size) { Ok(rngs) => for r in rngs { println!("Start {}, length {}", r.start, r.length) }, Err(err) => println!("HttpRange parse error: {:?}", err) }; } Used in iron-send-file...
Crate
v0.1.6
2026-10-19
docs.rs
...Usage In libraries Libraries should link only to the log crate, and use the provided macros to log whatever information will be useful to downstream consumers: [dependencies] log = "0.4" use log::{info, trace, warn}; pub fn shave_the_yak(yak: &mut Yak) { trace!("Commencing yak shaving"); loop { match find...
Crate
v0.4.35
2026-10-30
github.com
...Example use ciborium_ll::{Decoder, Header}; use ciborium_io::Read as _; let input = b"\x6dHello, World!"; let mut decoder = Decoder::from(&input[..]); let mut chunks = 0; match decoder.pull().unwrap() { Header::Text(len) => { let mut segments = decoder.text(len); while let Some(mut segment) = segments.pull().unwrap() { let mut buffer...
Crate
v0.2.2
2024-01-24
docs.rs
...let len = BENCHMARKS.len(); } The compiler will require that the static element type matches with the element type of the distributed slice. If the two do not match, the program will not compile: #[distributed_slice(BENCHMARKS)] static BENCH_WTF: usize = 999; error[E0308]: mismatched types --> src/distributed_slice.rs:65...
Crate
v0.3.38
2026-11-09
docs.rs
...Deserializer<'de>, { UntaggedEnumVisitor::new() .bool(|b| match b { false => Ok(LinkTimeOptimization::ThinLocal), true => Ok(LinkTimeOptimization::Fat), }) .string(|string| match string { "fat" => Ok(LinkTimeOptimization::Fat), "thin" => Ok(LinkTimeOptimization::Thin), "off" => Ok(LinkTimeOptimization::Off), _ => Err(serde::de::Error::invalid_value( Unexpected::Str(string), &r#""fat" or "thin" or "off""#, )), }) .deserialize(deserializer) } } License...
Crate
v0.1.9
2025-09-14
crates.io
...Installation Select a version of kube along matching versions of k8s-openapi and schemars for Kubernetes structs and matching schemas. See also historical Kubernetes versions . [dependencies] kube = { version = "4.2.0", features = ["runtime", "derive"] } k8s-openapi = { version = "0.28.0", features = ["latest", "schemars"] } schemars = { version = "1" } See features for a...
Crate
v4.2.1
2026-11-24