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...
struct Config<'a> {
name: &'a str,
value: &'a str,
}
fn parse_config(line: &str) -> Config {
fn calculate_length(s: &String) -> usize {
s.len()
}
fn append_suffix(s: &mut String) {
s.push_str(" world");
fn take_ownership(s: String) {
println!("Took ownership: {}", s);
} // s is dropped here
fn main() {
let message = String::from("hello");
use anyhow::{Context, Result};
use std::fs;
fn load_config(path: &str) -> Result<String> {
fs::read_to_string(path)
.with_context(|| format!("failed to read config from {}", path))
use thiserror::Error;
#[derive(Error, Debug)]
pub enum ConfigError {
#[error("file not found: {0}")]
NotFound(String),
use std::fs;
use std::num::ParseIntError;
fn read_port(path: &str) -> Result<u16, Box<dyn std::error::Error>> {
let contents = fs::read_to_string(path)?;
let port: u16 = contents.trim().parse()?;