crates.io
...These terms match the formula given on Wikipedia. avgdl ('average document length') is the aforementioned average meaningful token count; you should always provide a value for this and the crate can fit this for you. b controls document length normalization; 0 means no normalisation (length will not affect score) while...
Crate
v2.3.2
2025-09-07
docs.rs
...ip_address = Ipv6Addr::new(0x2001, 0xdb8, 0xdead, 0xbeef, 0, 0, 0, 0x1); assert_eq!(table.insert(network.clone(), "foo"), None); // Get value for network from table assert_eq!(table.longest_match(ip_address), Some((network, &"foo"))); Minimal required version of Rust compiler is 1.31 (because of ip_network crate).
Crate
v0.2.0
2021-07-12
docs.rs
...by default. .stdout(stdout) // Redirect stdout to `/tmp/daemon.out`. .stderr(stderr) // Redirect stderr to `/tmp/daemon.err`. .privileged_action(|| "Executed before drop privileges"); match daemonize.start() { Ok(_) => println!("Success, daemonized"), Err(e) => eprintln!("Error, {}", e), } } License Licensed under either of Apache License, Version 2.0 ( LICENSE-APACHE or http...
Crate
v0.5.0
2023-02-25
docs.rs
...In those cases you should use a version of xmltree that matches the version of xml you are using: xml version xmltree version 1 0.12 0.8 0.11 0.7 0.8 0.6 0.6 Example See the documentation for some examples: https://docs.rs/xmltree/
Crate
v0.12.0
2025-11-10
docs.rs
...use tokio::time::{Duration, sleep}; #[tokio::main] async fn main() { let (tx, mut rx) = bmrng::channel_with_timeout::<i32, i32>(100, Duration::from_millis(100)); tokio::spawn(async move { match rx.recv().await { Ok((input, mut responder)) => { sleep(Duration::from_millis(200)).await; let res = responder.respond(input * input); assert...
Crate
v0.5.2
2021-08-24
crates.io
...std")] { let (response_sender, response_receiver) = oneshot::channel(); let request = Request::from("data from sync thread"); processor.send((request, response_sender)).expect("Processor down"); match response_receiver.recv_timeout(Duration::from_secs(1)) { // <- Receive on the oneshot channel Ok(result) => println!("Processor returned {}", result), Err(oneshot::RecvTimeoutError::Timeout) => eprintln!("Processor...
Crate
v0.2.1
2026-02-23
github.com
...This matches the behavior of brotli with a custom dictionary as specified in https://datatracker.ietf.org/doc/draft-vandevenne-shared-brotli-format/ What's new in version 4.0.3 Better handling of corrupt brotli files. What's new in version 4.0.2 Better handling of corrupt brotli...
Crate
v6.4.0
2026-11-24
docs.rs
...find_executable_in_path is the most convenient function exported by this crate; given the name of an executable, it will yield the absolute path of the first matching file. use pathsearch::find_executable_in_path; if let Some(exe) = find_executable_in_path("ls") { println!("Found ls at {}", exe...
Crate
v0.2.0
2020-04-11
crates.io
...use similar::{ChangeTag, TextDiff}; fn main() { let diff = TextDiff::from_lines( "Hello World\nThis is the second line.\nThis is the third.", "Hallo Welt\nThis is the second line.\nThis is life.\nMoar and more", ); for change in diff.iter_all_changes() { let sign = match change.tag() { ChangeTag::Delete => "-", ChangeTag...
Crate
v3.2.1
2026-10-24
crates.io
...fn eval(e: &Expr) -> i64 { e.collapse_frames(|frame| match frame { ExprFrame::Add(a, b) => a + b, ExprFrame::Sub(a, b) => a - b, ExprFrame::Mul(a, b) => a * b, ExprFrame::LiteralInt(x) => x, }) } let expr = multiply(subtract(literal(1), literal(2)), literal(3)); assert_eq!(eval(&expr), -3); Here's...
Crate
v0.5.4
2025-06-09
github.com
...assert_eq!(Adler32::from_buf(&decompressed).finish(), checksum.unwrap()); // Verify that the decompressed data matches the original. assert_eq!(data, &decompressed[..]); For detail on more advanced usage, see the full API documentation . License Licensed under either of Apache License, Version 2.0 ( LICENSE-APACHE or http://www.apache.org/licenses...
Crate
v0.2.2
2026-11-01
dcuddeback.github.io
...extern crate libudev; fn main() { let context = libudev::Context::new().unwrap(); let mut enumerator = libudev::Enumerator::new(&context).unwrap(); enumerator.match_subsystem("tty").unwrap(); for device in enumerator.scan_devices().unwrap() { println!("found device: {:?}", device.syspath()); } } License Copyright © 2015 David Cuddeback Distributed under the MIT License .
Crate
v0.3.0
2021-01-17
crates.io
...use srcsrv::{SrcSrvStream, SourceRetrievalMethod}; if let Ok(srcsrv_stream) = pdb.named_stream(b"srcsrv") { let stream = SrcSrvStream::parse(srcsrv_stream.as_slice())?; let url = match stream.source_for_path( r#"C:\build\renderdoc\renderdoc\data\glsl\gl_texsample.h"#, r#"C:\Debugger\Cached Sources"#, )? { SourceRetrievalMethod::Download { url } => Some(url), _ => None...
Crate
v0.2.3
2025-03-07
docs.rs
...While checks are all tested // and must all succeed, allow/deny policies are tried one by one in order, // and we stop verification on the first that matches // // here we will check that the token has the corresponding right allow if right("/a/file1.txt", "read"); // explicit catch-all deny...
Crate
v7.0.0-alpha.4
2026-11-17
pyo3.rs
...Py_ssize_t, ) -> *mut PyObject { if nargs != 2 { PyErr_SetString( PyExc_TypeError, c"sum_as_string expected 2 positional arguments".as_ptr(), ); return std::ptr::null_mut(); } let (first, second) = (*args, *args.add(1)); let first = match parse_arg_as_i32(first, 1) { Some(x) => x, None => return std::ptr...
Crate
v0.30.1
2026-10-14
docs.rs
...Features Generates efficient data parsers and serialisers for structs and enums using #[derive] Reads and writes data from any source using standard io::Read and io::Write streams Directives in attributes handle common binary parsing tasks like matching magic numbers, byte ordering, padding & alignment, data validation, and more Includes reusable...
Crate
v0.15.2
2026-07-23
docs.rs
...Therefore, all events can be handled in a single match expression. Many functions (such as wait_for_event ) return a xcb::Result which allows idiomatic error handling. fn main() -> xcb::Result<()> { // ... loop { match conn.wait_for_event()? { xcb::Event::X(x::Event::KeyPress(key_press)) => { // do stuff } xcb::Event::Xkb...
Crate
v1.7.1
2026-08-09
crates.io
...writer.push(i).is_some() { // The ringbuffer is full, yield the thread std::thread::yield_now(); } }); // Loop that pulls elements from the ringbuffer loop { match reader.pull() { // We have got an element, do something Some(t) => std::hint::blackbox(t), // The ringbuffer is empty, yield the thread None => std::thread...
Crate
v0.2.2
2026-01-27
docs.rs
...for inner_pair in pair.into_inner() { match inner_pair.as_rule() { Rule::alpha => println!("Letter: {}", inner_pair.as_str()), Rule::digit => println!("Digit: {}", inner_pair.as_str()), _ => unreachable!() }; } } } This produces the following output: Rule: ident Span: Span { start: 0, end: 2 } Text: a1 Letter: a Digit: 1 Rule: ident...
Crate
v2.9.7
2026-11-24
docs.rs
...for inner_pair in pair.into_inner() { match inner_pair.as_rule() { Rule::alpha => println!("Letter: {}", inner_pair.as_str()), Rule::digit => println!("Digit: {}", inner_pair.as_str()), _ => unreachable!() }; } } } This produces the following output: Rule: ident Span: Span { start: 0, end: 2 } Text: a1 Letter: a Digit: 1 Rule: ident...
Crate
v2.9.7
2026-11-24