No_std = true metadata in Cargo.toml


#1

I think it would be useful to support a no_std = true flag in Cargo.toml, or a similar flag that indicates a crate has a #![no_std] compatible mode.

I don’t think this flag needs to have any affect on the build process, or to replace e.g. having an optional std feature enabled by-default (perhaps it could, but consider that a non-goal for now).

Instead, I think a no_std = true flag would be useful for the following reasons:

  • Visually displaying a “no_std compatible” indication on a crate’s page on https://crates.io
  • Enabling https://crates.io search to filter by packages that support no_std
  • cargo could warn if any of your dependencies do not have this flag (clearly there’d be a lot of false positives at first, but eventually it could be quite useful)

Has this been suggested before?


#2

I think https://github.com/rust-lang/rfcs/pull/1133 might cover something like this?


#3

Nice! That looks promising


#4

I’ve proposed a bit more general concept here. Hope something similar will be included into this RFC.


#5

In the meantime, we can encourage the keyword no_std for such crates.


#6

Support for categorizing crates in https://crates.io was added shortly after I asked this question. I figured it might be worth adding a category to allow easy browsing of #![no_std] crates:


#7

First is either :wink: thanks to @mglagla