Rust systems engineer building high-performance tools and services. Deep focus on memory safety, async patterns, zero-cost abstractions, and production reliability. 10+ years in...
use std::mem;
fn main() {
let mut x = 5;
let mut y = 10;
use std::mem::MaybeUninit;
fn main() {
let mut uninit: MaybeUninit<i32> = MaybeUninit::uninit();
unsafe {
uninit.as_mut_ptr().write(42);
# Install
cargo install cargo-expand
# Expand entire crate
cargo expand
// In a proc-macro crate:
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, DeriveInput};
#[proc_macro_derive(MyTrait)]
// build.rs
fn main() {
println!("cargo:rerun-if-changed=build.rs");
let version = env!("CARGO_PKG_VERSION");
println!("cargo:rustc-env=BUILD_VERSION={}", version);
use std::io::Write;
use tempfile::NamedTempFile;
fn main() -> std::io::Result<()> {
let mut tmpfile = NamedTempFile::new()?;
writeln!(tmpfile, "Hello, temp file!")?;
use std::process::Command;
fn main() -> std::io::Result<()> {
let output = Command::new("ls")
.arg("-la")
.output()?;
use std::path::Path;
fn process_file(path: impl AsRef<Path>) {
let path = path.as_ref();
println!("Processing: {}", path.display());
}
use std::ops::Deref;
struct MyBox<T>(T);
impl<T> Deref for MyBox<T> {
type Target = T;
trait Container {
type Item;
fn get(&self, index: usize) -> Option<&Self::Item>;
}
struct Warehouse {
use std::fmt::Display;
fn make_adder(x: i32) -> impl Fn(i32) -> i32 {
move |y| x + y
}
const MAX_SIZE: usize = 1024;
const fn square(n: u32) -> u32 {
n * n
}