crates.io
...Example use urlpattern::UrlPattern; use urlpattern::UrlPatternInit; use urlpattern::UrlPatternMatchInput; fn main() { // Create the UrlPattern to match against. let init = UrlPatternInit { pathname: Some("/users/:id".to_owned()), ..Default::default() }; let pattern = <UrlPattern>::parse(init, Default::default()).unwrap(); // Match the pattern against a URL. let url = "https://example.com/users/123...
Crate
v0.6.0
2026-02-12
docs.rs
...Partial matching If you want to assert that one JSON value is "included" in another use assert_json_include : use assert_json_diff::assert_json_include; use serde_json::json; let a = json!({ "data": { "users": [ { "id": 1, "country": { "name": "Denmark" } }, { "id": 24, "country": { "name": "Denmark" } } ] } }); let b = json!({ "data": { "users...
Crate
v2.0.2
2022-06-29
docs.rs
CSS Selectors matching for Rust rust-selectors Documentation crates.io CSS Selectors library for Rust. Includes parsing and serialization of selectors, as well as matching against a generic tree of elements. Pseudo-elements and most pseudo-classes are generic as well. Warning: breaking changes are made to this library fairly...
Crate
v0.40.0
2026-08-04
crates.io
...How to get a compatible version of protoc The protoc binary that you use to generate code needs to have a version that exactly matches the version of the protobuf crate you are using. More specifically, if you are using Rust protobuf x.y.z then you need to use...
Crate
v4.36.0-rc.2
2026-08-03
crates.io
...std::iter::Iterator<Item = <A as std::iter::Iterator>::Item>, { type Item = <A as std::iter::Iterator>::Item; fn next(&mut self) -> Option<Self::Item> { match self { Enum::A(x) => x.next(), Enum::B(x) => x.next(), } } fn size_hint(&self) -> (usize, Option<usize>) { match self { Enum::A(x) => x...
Crate
v0.16.0
2026-07-24
crates.io
...They're efficient and convenient for matching events or defining hardcoded keybindings. match key_event.into() { key!(ctrl-c) => { println!("Arg! You savagely killed me with a {}", fmt.to_string(key_event).red()); break; } key!(ctrl-q) => { println!("You typed {} which gracefully quits", fmt.to_string(key_event).green()); break...
Crate
v1.5.0
2026-07-24
github.com
...Vec<(&'static str, Value)>, encoder: &'a Encoder, ) -> FutureRecord<'a> { let subject_name_strategy = SubjectNameStrategy::TopicNameStrategy(topic, false); let payload = match encoder.encode(values, &subject_name_strategy) { Ok(v) => v, Err(e) => panic!("Error getting payload: {}", e), }; FutureRecord { topic, partition: None, payload: Some(&payload), key, timestamp: None, headers: None, } } fn get...
Crate
v4.10.0
2026-07-13
crates.io
...Catch-all variant Sometimes it is desirable to have an Other variant which holds the otherwise un-matched value as a field. The #[num_enum(catch_all)] attribute allows you to mark at most one variant for this purpose. The variant it's applied to must be a tuple variant...
Crate
v0.7.6
2026-03-15
crates.io
...Catch-all variant Sometimes it is desirable to have an Other variant which holds the otherwise un-matched value as a field. The #[num_enum(catch_all)] attribute allows you to mark at most one variant for this purpose. The variant it's applied to must be a tuple variant...
Crate
v0.7.6
2026-03-15
softprops.github.io
...Option<u64> } fn main() { match envy::from_env::<Config>() { Ok(config) => println!("{:#?}", config), Err(error) => panic!("{:#?}", error) } } ... export some environment variables $ FOO=8080 BAR=true BAZ=hello yourapp You should be able to access a completely typesafe config struct deserialized from env vars. Envy assumes an env var exists for...
Crate
v0.4.2
2021-01-04
crates.io
...a test my_test that accepts a path, and optionally the contents as input a directory to look for files (test fixtures) in a pattern to match files on datatest-stable will call the my_test function once per matching file in the directory. Directory traversals are recursive. datatest-stable...
Crate
v0.3.3
2026-03-31
crates.io
Generates random strings and byte strings matching a regex rand_regex Generates random strings and byte strings matching a regex. Examples use rand::{SeedableRng, Rng}; let mut rng = rand_xorshift::XorShiftRng::from_seed(*b"The initial seed"); // creates a generator for sampling strings let grx = rand_regex::Regex::compile(r...
Crate
v0.19.0
2026-02-24
sentry.io
...use sentry_log::LogFilter; let logger = sentry_log::SentryLogger::new().filter(|md| match md.level() { log::Level::Error => LogFilter::Event, _ => LogFilter::Ignore, }); Sending multiple items to Sentry To map a log record to multiple items in Sentry, you can combine multiple log filters using the bitwise or operator: use sentry...
Crate
v0.49.1
2026-08-03
solang.readthedocs.io
...function get() public view returns (bool) { return value; } } "#, 0).unwrap(); for part in &tree.0 { match part { SourceUnitPart::ContractDefinition(def) => { println!("found contract {:?}", def.name); for part in &def.parts { match part { ContractPart::VariableDefinition(def) => { println!("variable {:?}", def.name); } ContractPart::FunctionDefinition(def) => { println!("function {:?}", def.name); } _ => (), } } } _ => (), } }
Crate
v0.3.5
2025-06-22
docs.rs
...Parsing use svg::node::element::path::{Command, Data}; use svg::node::element::tag::Path; use svg::parser::Event; let path = "image.svg"; let mut content = String::new(); for event in svg::open(path, &mut content).unwrap() { match event { Event::Tag(Path, _, attributes) => { let data = attributes.get("d").unwrap(); let data...
Crate
v0.18.0
2024-09-27
crates.io
Glob-matched recursive file system walking. GlobWalk Recursively find files in a directory using globs. This crate is now in a perpetual maintnance mode and new users should probably cosider using glob . Comparison to the glob crate This crate was origially written years ago, when glob was a very differet...
Crate
v0.9.1
2024-01-06
docs.rs
A fast library for efficiently matching ignore files such as `.gitignore`
against file paths.
ignore The ignore crate provides a fast recursive directory iterator that respects various filters such as globs, file types and .gitignore files. This crate also provides lower level direct access to gitignore and file type matchers...
Crate
v0.4.33
2026-08-04
docs.rs
...server.expect( Expectation::matching(request::method_path("GET", "/foo")).respond_with(status_code(200)), ); // Configure the server to also receive between 1 and 3 POST /bar requests // with a json body matching {'foo': 'bar'}, and respond with a json body // {'result': 'success'} server.expect( Expectation::matching(all_of![ request::method...
Crate
v0.16.4
2026-01-06
crates.io
...use jiff::{ToSpan, Zoned}; use parse_datetime::{parse_datetime_at_date, ParsedDateTime}; let now = Zoned::now(); let after = parse_datetime_at_date(now.clone(), "+3 days"); match after.unwrap() { ParsedDateTime::InRange(z) => assert_eq!(now.checked_add(3.days()).unwrap(), z), ParsedDateTime::Extended(_) => unreachable!("unexpected for this input"), } For DateTime...
Crate
v0.15.0
2026-07-05
crates.io
...When the specified expectations do not match the received request, mock.assert() fails the test with a detailed error description, including a diff that shows the differences between the expected and actual HTTP requests. Example: 0 of 1 expected requests matched the mock specification. Here is a comparison with the...
Crate
v0.8.3
2026-02-04