The snippet library.
Small, practical examples. Search by task or narrow things down below.
Bind a value with let
Bind a value with let in a complete Rust program using the standard library.
Rust✓ Tested
Borrow text without transferring ownership
Borrow text without transferring ownership in a complete Rust program using the standard library.
Rust✓ Tested
Calculate an order subtotal
Calculate an order subtotal in a complete Rust program using the standard library.
Rust✓ Tested
Call a typed function
Call a typed function in a complete Rust program using the standard library.
Rust✓ Tested
Choose an action with match
Choose an action with match in a complete Rust program using the standard library.
Rust✓ Tested
Choose floating-point arithmetic
Choose floating-point arithmetic in a complete Rust program using the standard library.
Rust✓ Tested
Clone an owned value explicitly
Clone an owned value explicitly in a complete Rust program using the standard library.
Rust✓ Tested
Combine Boolean conditions
Combine Boolean conditions in a complete Rust program using the standard library.
Rust✓ Tested
Compile and run your first Rust program
Compile and run your first Rust program in a complete Rust program using the standard library.
Rust✓ Tested
Construct a named-field struct
Construct a named-field struct in a complete Rust program using the standard library.
Rust✓ Tested
Create a fixed-size array
Create a fixed-size array in a complete Rust program using the standard library.
Rust✓ Tested
Declare a typed constant
Declare a typed constant in a complete Rust program using the standard library.
Rust✓ Tested