Skip to main content

index

@ts-rust/std


@ts-rust/std

Modules

ModuleDescription

Error

The Error module provides a base error class for handling errors in a consistent way across the @ts-rust/std library. It exports the AnyError class, which serves as a generic error type that can be extended or used directly to represent errors in Option and Result types. Use this module to create or handle custom errors in a type-safe manner within your TypeScript applications.

Option

The Option module provides utilities for handling optional values in a type-safe manner. Inspired by Rust's Option type, this module offers the Option and PendingOption types to represent values that may or may not be present (Some or None). It includes type definitions for Option, PendingOption, and related error types, as well as utility functions for creating and checking Option instances. Use this module to avoid null/undefined errors and write more explicit, safer TypeScript code.

Result

The Result module provides utilities for handling operations that can succeed or fail in a type-safe manner. Inspired by Rust's Result type, this module offers the Result and PendingResult types to manage success (Ok) and failure (Err) cases explicitly. It includes type definitions for Result, PendingResult, and related error types, as well as utility functions for creating and checking Result instances. Use this module to write more predictable and robust TypeScript code by enforcing explicit error handling.

Types

The Types module defines common utility types used throughout the @ts-rust/std package. It exports foundational types such as Primitive, Cloneable, Clone, Recoverable, and MaybePromise, which provide building blocks for type-safe programming in TypeScript. Inspired by Rust's type system, these types enable better handling of cloning, error recovery, and synchronous/asynchronous value interoperability. Use this module to leverage these utility types in your TypeScript applications for more robust and predictable code.