No_std = true metadata in Cargo.toml

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?

1 Like

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

Nice! That looks promising

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

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

1 Like

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:

2 Likes

First is either :wink: thanks to @mglagla

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