Introducing standback: portions of the standard library backported to support older compilers

Introducing standback


There are an increasing number of stabilizations with every release. Ever wanted to use newly-stabilized features in a crate or published binary, but decided against it because it would mean bumping the minimum supported Rust version? This is a situation many authors have to deal with, and it's not always clear when to bump the MSRV, even when soundness is an issue (see mem::uninitialized() vs mem::MaybeUninit).

Standback (from "standard library" and "backport") helps you out here. It has a minimum supported Rust version of 1.31, and has a ton of APIs that have been backported. Nearly all of this code comes directly from the standard library itself, so it can definitely be trusted. Oh, and it's also #![no_std] compatible to a large extent.

If all you're doing is using a newly stabilized method (not an import), just add use standback::prelude::*; to the top of your file. If what you're using is something that must be imported, replace std with standback. For example, to import the TryFrom trait in Rust 1.31: use standback::convert::TryFrom;.

Standback will automatically determine the compiler version in use, and will happily re-export an import if it has been stabilized. This ensures that you can confidently use a type even if it has been stabilized — and do so at nearly zero cost!

Hopefully this proves to be a useful project to the Rust community at large. Surprisingly, it actually wasn't too much effort to put this together. I intend on keeping this up-to-date with each Rust release, so the functionality will continue to improve at (nearly) the same speed as std :slightly_smiling_face:. After some looking things over to ensure nothing is terribly buggy (or plain doesn't compile), my intent is to maintain a 0.X release, where X is the current compiler version (so 0.41 right now).

NB: If you're actively compiling on an older compiler (in CI, for example), you'll likely want to #![allow(unstable_name_collisions)] on those older versions. That is the whole point of this crate, after all.


This sounds amazing, good job!

I love this. Thanks a lot!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.