Add support for alloc::* types
Pzixel opened this issue ยท 10 comments
Currently I have following errors:
error[E0277]: the trait bound `alloc::String: serde::Serialize` is not satisfied
--> C:\Users\Alex\Documents\Repo\pwasm-abi\derive\src\json.rs:14:10
|
14 | #[derive(Serialize, Debug)]
| ^^^^^^^^^ the trait `serde::Serialize` is not implemented for `alloc::String`
|
= note: required by `serde::ser::SerializeStruct::serialize_field`
Could it be done in no-std scenario?
Yes, I carefully read that you don't support dynamic allocated types, but serde_json crate claims that they don't support no_std at all. So I'm in the situation where struct Foo(String) cannot be serialized, not with this crate or serde_json or any other.
But they clearly say "It won't work, and even if it would, I won't support and/or accept any issues caused by this". It's kinda unstable situation.
Can you please provide a reference to that claim? A crate can be (not no_std) + alloc. For many operations, the alloc equivalents could be used.
I don't intend to bring no-std support into serde_json as discussed previously in #362.
I reconsidered and would be willing to consider a serde_json PR to use alloc. serde-rs/json#362 (comment)
I too would appreciate if the library used alloc crate types if there was an alloc feature enabled. Now I'm forced to use heapless String type instead of the alloc crate String type if I call to_string for example.
FWIW serde_json should support using only alloc via (now merged) serde-rs/json#606
AFAICT this can be closed as both not pertinent to serde-json-core and resolved in serde-json.
Thank you everybody!