Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for alloc::* types #4

Closed
Pzixel opened this issue Jul 18, 2018 · 10 comments
Closed

Add support for alloc::* types #4

Pzixel opened this issue Jul 18, 2018 · 10 comments

Comments

@Pzixel
Copy link

Pzixel commented Jul 18, 2018

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?

@Pzixel Pzixel changed the title Add support for Vec serialization Add support for alloc::* types Jul 18, 2018
@Pzixel
Copy link
Author

Pzixel commented Jul 18, 2018

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.

@sanmai-NL
Copy link

@Pzixel: the solution would be for serde_json to use the alloc crate.

@Pzixel
Copy link
Author

Pzixel commented Oct 18, 2018

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.

@sanmai-NL
Copy link

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.

@Pzixel
Copy link
Author

Pzixel commented Oct 18, 2018

serde-rs/json#463 (comment)

I don't intend to bring no-std support into serde_json as discussed previously in #362.

@dtolnay
Copy link

dtolnay commented Oct 18, 2018

I reconsidered and would be willing to consider a serde_json PR to use alloc. serde-rs/json#362 (comment)

@jonimake
Copy link

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.

@Xanewok
Copy link

Xanewok commented Jan 22, 2020

FWIW serde_json should support using only alloc via (now merged) serde-rs/json#606

@jordens
Copy link
Contributor

jordens commented Dec 30, 2023

AFAICT this can be closed as both not pertinent to serde-json-core and resolved in serde-json.

@eldruin
Copy link
Member

eldruin commented Dec 31, 2023

Thank you everybody!

@eldruin eldruin closed this as completed Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants