$ show smol-rs/smol
Smol is a lightweight async runtime for Rust that bundles several well-known subcrates (async-executor, async-io, async-net, async-fs, async-process, async-channel, async-lock, blocking, futures-lite) into a single convenient dependency. It provides a global executor initialized lazily with configurable thread count via the SMOL_THREADS environment variable, and exposes a simple API (smol::spawn, smol::block_on, smol::Async, smol::Timer, smol::Unblock, etc.) for writing async programs. The source code itself is thinβprimarily re-exports from subcrates plus a spawn module that sets up the global executor. This makes smol an excellent entry point for Rust async development without the complexity of larger runtimes like tokio. The repository includes a rich set of examples covering TCP, TLS, HTTP, WebSocket, file I/O, process management, and platform-specific features like inotify and timerfd. The codebase is well-maintained, uses modern Rust practices (edition 2021, MSRV 1.85, no unsafe), and has active CI and dependabot configuration.
The LLM identified 1 files worth highlighting for reuse:
Implements a global async executor using a OnceLock for lazy initialization. Creates background threads (default 1, configurable via SMOL_THREADS env var) that run the executor with a pending future to keep them alive. On the main thread, also runs the async-process driver. This is a clean, self-contained pattern that can be extracted to provide a global executor in any async Rust application. It demonstrates safe usage of OnceLock, thread spawning, and catch_unwind for resilience.