TypeScript standard types inspired by Rust's powerful type system.
This monorepo provides TypeScript implementations of Rust's essential types for error handling and null-safe programming. It includes:
- @rustify/option - Pure TypeScript Option type for null-safe programming
- @rustify/result - Pure TypeScript Result type for robust error handling
- 🦀 Rust-inspired: Faithful TypeScript implementation of Rust's Option and Result types
- 🔒 Type-safe: Full TypeScript support with proper type guards and inference
- 🌳 Tree-shakable: ES modules with sideEffects: false
- 📦 Zero dependencies: Pure TypeScript with no external runtime dependencies
- 🧪 Well-tested: Comprehensive test coverage
- 🔧 Modern tooling: Built with Vite, tested with Vitest, linted with Biome
# Install both packages
pnpm add @rustify/option @rustify/result
# Or install individually
pnpm add @rustify/option
pnpm add @rustify/resultimport{Option,Some,None}from'@rustify/option';// Create optionsconstvalue=Some(42);constempty=None;// Safe operationsconstdoubled=value.map(x=>x*2);// Some(84)constresult=value.unwrapOr(0);// 42import{Result,Ok,Err}from'@rustify/result';// Create resultsconstsuccess=Ok("Hello");constfailure=Err("Something went wrong");// Safe error handlingconstprocessed=success.map(s=>s.toUpperCase());// Ok("HELLO")constfallback=failure.unwrapOr("Default");// "Default"This project uses pnpm workspaces for managing the monorepo.
pnpm installpnpm buildpnpm testpnpm devpnpm lint
pnpm format- Node.js >= 22.0.0
- pnpm >= 10.13.1
MIT