rust

rust
use std::env;

fn main() {
    let port: u16 = env::var("PORT")
        .unwrap_or_else(|_| "8080".to_string())
        .parse()

Environment variables with std::env for configuration

rust config environment
by Marcus Chen 1 tab
rust
use std::collections::VecDeque;

fn main() {
    let mut queue = VecDeque::new();
    queue.push_back(1);
    queue.push_back(2);

VecDeque<T> for double-ended queue operations

rust collections
by Marcus Chen 1 tab
rust
use axum::{routing::get, Router, Json};
use serde::Serialize;

#[derive(Serialize)]
struct Response {
    message: String,

axum for type-safe async HTTP servers

rust async axum
by Marcus Chen 1 tab
rust
use tokio::time::{sleep, Duration};

#[tokio::main]
async fn main() {
    let fast = sleep(Duration::from_millis(50));
    let slow = sleep(Duration::from_millis(200));

tokio::select! for racing multiple async operations

rust async tokio
by Marcus Chen 1 tab
rust
use criterion::{black_box, criterion_group, criterion_main, Criterion};

fn fibonacci(n: u64) -> u64 {
    match n {
        0 => 1,
        1 => 1,

Criterion for benchmarking with statistical analysis

rust benchmarking performance
by Marcus Chen 1 tab
rust
use std::fmt::Display;

fn print_it<T: Display>(value: T) {
    println!("Value: {}", value);
}

Trait bounds for generic functions with behavior constraints

rust traits generics
by Marcus Chen 1 tab
rust
use reqwest;
use serde::Deserialize;

#[derive(Deserialize, Debug)]
struct Post {
    id: u32,

reqwest for async HTTP client with connection pooling

rust http async
by Marcus Chen 1 tab
rust
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ConfigError {
    #[error("file not found: {0}")]
    NotFound(String),

Custom error types with thiserror for domain errors

rust error-handling libraries
by Marcus Chen 1 tab
rust
use std::path::Path;

fn process_file(path: impl AsRef<Path>) {
    let path = path.as_ref();
    println!("Processing: {}", path.display());
}

AsRef and AsMut for flexible function parameters

rust traits conversion
by Marcus Chen 1 tab
rust
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn greet(name: &str) -> String {
    format!("Hello, {}!", name)
}

wasm-bindgen for Rust to JavaScript interop in WebAssembly

rust wasm webassembly
by Marcus Chen 1 tab
rust
extern "C" {
    fn abs(input: i32) -> i32;
}

pub fn safe_abs(input: i32) -> i32 {
    unsafe { abs(input) }

Unsafe Rust for FFI and low-level optimizations

rust unsafe ffi
by Marcus Chen 1 tab
rust
use axum::{Router, routing::get};
use tower::ServiceBuilder;
use tower_http::{trace::TraceLayer, timeout::TimeoutLayer};
use std::time::Duration;

async fn handler() -> &'static str {

Tower middleware for composable HTTP service layers

rust tower middleware
by Marcus Chen 1 tab