lloydmeta / frunk

Funktional generic type-level programming in Rust: HList, Coproduct, Generic, LabelledGeneric, Validated, Monoid and friends.
https://beachape.com/frunk/
MIT License
1.24k stars 56 forks source link

`Validated`/`no_std`: replace `std::Vec` dependency with `alloc::Vec` #220

Closed mammothbane closed 5 days ago

mammothbane commented 1 year ago

Would you be open to a PR to conditionally replace the use of std::Vec in frunk::Validated with alloc::Vec? At a quick glance, I believe this is the only required change to make the whole project work in no_std-but-alloc environments.

ExpHP commented 1 year ago

Does it need to be conditional? I'm not familiar with usage of or best practices involving the alloc crate, but I would suspect that if it is possible to always use alloc over std when possible then that would be preferred.

ExpHP commented 1 year ago

Oh yeah, I just remembered we have this:

#[cfg(not(feature = "std"))]
extern crate core as std;

Not 100% sure but I think that's a relic from a time back when you couldn't use core:: without no_std?? These days you can use use core:: from any crate and that's what I think we ought to be doing for the things that don't require std.

Edit: hmm yeah, I wrote that line ages ago but didn't document why. Either it was needed at the time, or I was simply too lazy to fix all of our uses across the crate, but it seems worth doing now.