technocreatives / core2

The bare essentials of std::io for use in no_std. Alloc support is optional.
https://docs.rs/core2
Apache License 2.0
70 stars 23 forks source link
compat const-generics embedded no-alloc no-std polyfill rust traits

core2

Actions Status Documentation Minimum Supported Rust Version (MSRV)

Ever wanted a Cursor or the Error trait in no_std? Well now you can have it. A 'fork' of Rust's std modules for no_std environments, with the added benefit of optionally taking advantage of alloc.

The goal of this crate is to provide a stable interface for building I/O and error trait functionality in no_std environments. The current code corresponds to the most recent stable API of Rust 1.47.0. It is also a goal to achieve a true alloc-less experience, with opt-in alloc support.

This crate works on stable with some limitations in functionality, and nightly without limitations by adding the relevant feature flag.

This crate is std by default -- use no default features to get no_std mode.

Usage

[dependencies]
core2 = "0.3"

Add the crate, use the things you would usually want from std::io, but instead from core2::io, and use core2::error::Error in place of std::error::Error.

Features

Differences to std::io

Other than items perhaps being entirely missing or certain functions unavailable on some traits, no function signatures have been changed.

Limitations

Where is it used?

All of the below are works in progress, but should help with demonstrating how to use this crate.

License

Licensed under either of

at your option.


Almost all of the code in this repository is a copy of the Rust language codebase with minor modifications.

For attributions, see https://thanks.rust-lang.org/.