2025-09-15 21:21:30 -04:00
|
|
|
# `std` shims
|
2023-04-22 04:38:47 -04:00
|
|
|
|
2025-09-15 21:21:30 -04:00
|
|
|
`std-shims` is a Rust crate with two purposes:
|
|
|
|
|
- Expand the functionality of `core` and `alloc`
|
|
|
|
|
- Polyfill functionality only available on newer version of Rust
|
2023-04-22 04:38:47 -04:00
|
|
|
|
2025-09-15 21:21:30 -04:00
|
|
|
The goal is to make supporting no-`std` environments, and older versions of
|
|
|
|
|
Rust, as simple as possible. For most use cases, replacing `std::` with
|
|
|
|
|
`std_shims::` and adding `use std_shims::prelude::*` is sufficient to take full
|
|
|
|
|
advantage of `std-shims`.
|
2025-08-19 13:36:01 -04:00
|
|
|
|
2025-09-15 21:21:30 -04:00
|
|
|
# API Surface
|
|
|
|
|
|
|
|
|
|
`std-shims` only aims to have items _mutually available_ between `alloc` (with
|
|
|
|
|
extra dependencies) and `std` publicly exposed. Items exclusive to `std`, with
|
|
|
|
|
no shims available, will not be exported by `std-shims`.
|
|
|
|
|
|
|
|
|
|
# Dependencies
|
|
|
|
|
|
|
|
|
|
`HashSet` and `HashMap` are provided via `hashbrown`. Synchronization
|
|
|
|
|
primitives are provided via `spin` (avoiding a requirement on
|
|
|
|
|
`critical-section`). Sections of `std::io` are independently matched as
|
|
|
|
|
possible. `rustversion` is used to detect when to provide polyfills.
|
|
|
|
|
|
|
|
|
|
# Disclaimer
|
|
|
|
|
|
|
|
|
|
No guarantee of one-to-one parity is provided. The shims provided aim to be
|
|
|
|
|
sufficient for the average case. Pull requests are _welcome_.
|