askama.rs
...templates` dir in the crate root struct HelloTemplate<'a> { // the name of the struct can be anything name: &'a str, // the field name should match the variable name // in your template } fn main() { let hello = HelloTemplate { name: "world" }; // instantiate your struct println!("{}", hello.render().unwrap()); // then render it. } You should...
Crate
v0.16.1
2026-09-04
github.com
...templates` dir in the crate root struct HelloTemplate<'a> { // the name of the struct can be anything name: &'a str, // the field name should match the variable name // in your template } fn main() { let hello = HelloTemplate { name: "world" }; // instantiate your struct println!("{}", hello.render().unwrap()); // then render it. } You should...
Crate
v0.16.1
2026-09-04
askama.rs
...templates` dir in the crate root struct HelloTemplate<'a> { // the name of the struct can be anything name: &'a str, // the field name should match the variable name // in your template } fn main() { let hello = HelloTemplate { name: "world" }; // instantiate your struct println!("{}", hello.render().unwrap()); // then render it. } You should...
Crate
v0.16.1
2026-09-04
docs.rs
...let mut lru_cache = LinkedHashMap::new(); let key = "key".to_owned(); // Try to find my expensive to construct and hash key let _cached_val = match lru_cache.raw_entry_mut().from_key(&key) { RawEntryMut::Occupied(mut occupied) => { // Cache hit, move entry to the back. occupied.to_back(); occupied.into_mut...
Crate
v0.12.2
2026-09-07
crates.io
...Fuzz tests verify the hand-written parser never panics and matches a nom-based reference implementation. light-weight. Minimal dependencies; uses Cargo features so callers can avoid them when undesired. Simple code that minimizes monomorphization bloat. Small data structures; eg http_auth::DigestClient currently weighs in at 32 bytes plus...
Crate
v0.1.10
2024-08-31
github.com
...use versions::{Requirement, Versioning}; let req = Requirement::new("^1.2.3").unwrap(); let ver = Versioning::new("1.2.4").unwrap(); assert!(req.matches(&ver)); In this case, the incoming version 1.2.4 satisfies the "caret" constraint, which demands anything greater than or equal to 1.2.3 . See the...
Crate
v8.0.1
2026-09-14
crates.io
...f64, } impl C { fn dbg_inner(&self) -> usize { dbg!(self.val_c); 3 } } impl Enum { delegate! { // transformed to // // ```rust // match self { // Enum::A(a) => a.dbg_inner(), // Enum::B(b) => { println!("i am b"); b }.dbg_inner(), // Enum::C { v: c } => { c }.dbg_inner(), // } // ``` to match self { Enum::A(a...
Crate
v0.13.5
2025-12-10
docs.rs
...If the dependency is not specified in the configuration, wasm-compose will search the configured search paths for a matching component file. If a component to satisfy the dependency cannot be found, it will remain as an instance import in the composed component; at least one dependency must be satisfied...
Crate
v0.263.0
2026-10-30
crates.io
...This can be particularly handy with match statements. /// A trait for managing 8-byte discriminators in a slab of bytes pub trait SplDiscriminate { /// The 8-byte discriminator as a `[u8; 8]` const SPL_DISCRIMINATOR: ArrayDiscriminator; /// The 8-byte discriminator as a slice (`&[u8]`) const SPL_DISCRIMINATOR_SLICE: &'static [u8] = Self...
Crate
v0.5.2
2026-03-23
docs.rs
...Crate containers mirror the stable API of the matched Rust containers and forward to them as much as possible. TiSlice and TiVec can be easily converted to matched Rust containers and back using From , Into , AsRef and AsMut traits. Also, they expose raw property with the original data type. Containers...
Crate
v4.0.0-alpha.3
2026-11-17
docs.rs
...extern crate udev; fn main() { let mut enumerator = udev::Enumerator::new().unwrap(); enumerator.match_subsystem("tty").unwrap(); for device in enumerator.scan_devices().unwrap() { println!("found device: {:?}", device.syspath()); } } Thread-safety The udev-api does not have any thread-safety guarantees, however many implementations are indeed thread-safe. If you...
Crate
v0.9.3
2025-01-23
github.com
...use ratelimit::Ratelimiter; // 10,000 requests/s let ratelimiter = Ratelimiter::new(10_000); loop { match ratelimiter.try_wait() { Ok(()) => { // token acquired -- perform rate-limited action break; } Err(wait) => { // rate limited -- sleep and retry std::thread::sleep(wait); } } } For more control over burst capacity and initial tokens: use ratelimit::Ratelimiter; let...
Crate
v2.0.0
2026-04-21
crates.io
...We want to perform one operation on all the leading contiguous // elements that match some predicate, and a different thing with the rest of // the elements. With the `xs`, we will use the normal `take_while`. With the // `ys`, we will use `peeking_take_while`. let xs: Vec<u8> = (0...
Crate
v1.0.0
2021-09-03
docs.rs
...a=e op='*' b=e # mult | left=e '+' b=e # add For such rule ANTLR will generate enum EContextAll with a MultContext and an AddContext variant (plus an Error variant), so you will be able to match on them in your code. Also corresponding struct for each alternative will contain...
Crate
v0.6.0
2026-09-27
crates.io
...Features Selector matching support. The rules are sorted by specificity. !important parsing support. Has a high-level parsers and low-level, zero-allocation tokenizers. No unsafe. Minimum supported Rust Version (MSRV) This version of SimpleCSS has been verified to compile with Rust 1.65 and later. Future versions of SimpleCSS...
Crate
v0.2.2
2025-01-06
docs.rs
...use lebe::Endian; fn main(){ let mut numbers: &[i32] = &[ 32, 102, 420, 594 ]; numbers.convert_current_to_little_endian(); } Why not use byteorder ? This crate supports batch-writing slices with native speed where the os has the matching endianness. Writing slices in byteorder must be done manually, and may be...
Crate
v0.5.3
2025-09-06
philbooth.gitlab.io
...Bom = "foo.txt".parse().unwrap(); match bom { Bom::Null => { // No BOM was detected } Bom::Bocu1 => { // BOCU-1 BOM was detected } Bom::Gb18030 => { // GB 18030 BOM was detected } Bom::Scsu => { // SCSU BOM was detected } Bom::UtfEbcdic => { // UTF-EBCDIC BOM was detected } Bom::Utf1 => { // UTF-1 BOM was detected } Bom::Utf7 => { // UTF...
Crate
v2.0.3
2023-11-13
lib.rs
...TlsStream<TcpStream>) { // ... } for stream in listener.incoming() { match stream { Ok(stream) => { let acceptor = acceptor.clone(); thread::spawn(move || { let stream = acceptor.accept(stream).unwrap(); handle_client(stream); }); } Err(e) => { /* connection failed */ } } } } Supported features This crate supports the following features out of the box: TLS/SSL client communication TLS/SSL server...
Crate
v0.2.18
2026-02-18
crates.io
...FluentLanguageLoader = fluent_language_loader!(); loader .load_languages(&Localizations, &[loader.fallback_language().clone()]) .unwrap(); assert_eq!( "Hello \u{2068}Bob 23\u{2069}!", // Compile time check for message id, and the `name` argument, // to ensure it matches what is specified in the `fallback_language`'s // fluent resource file. fl!(loader, "hello...
Crate
v0.10.1
2026-07-23
docs.rs
...formatting, filters, and output can be applied recursively to match increasingly specific kinds of logging. Fern provides a builder-based configuration backing for rust's standard log crate. //! With fern, we can: // Configure logger at runtime fern::Dispatch::new() // Perform allocation-free log formatting .format(|out, message, record| { out.finish...
Crate
v0.7.1
2024-12-15