EmbarkStudios / mirror-mirror

🪞 Powerful reflection library for Rust
Apache License 2.0
79 stars 2 forks source link

`#![no_std]` Support #14

Closed XAMPPRocky closed 1 year ago

XAMPPRocky commented 1 year ago

I was scrolling through the org github and just happened to see this. 😄 I was interested in trying it out in one of my project, and I was wondering if you'd consider adding #![no_std] support? As far as I can tell nearly all of the crate is implemented with types in core and alloc, having it available without std would allow this to be used by a lot more lower level libraries such as codec/serialisation frameworks.

davidpdrsn commented 1 year ago

Sure! I've never actually done a non_std crate before so would be cool to try.

Is there more to it than using the types from core and alloc?

XAMPPRocky commented 1 year ago

Is there more to it than using the types from core and alloc?

For libraries nope, all you do is use those types, and set #![no_std] in the root. For applications it's more complicated as you need to specify your main/start function (of course you can use no_std libraries in std applications no problem).

If you want to add std support for select types, you should typically have the crate be #[no_std] by default, and provide a std feature (rather than opposite, having it default to std and then enabling a no_std feature.), as that makes default-features = false behave intuitively.