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

Fix support for #![no_std] and serde #182

Closed
vic1707 opened this issue Sep 12, 2024 · 0 comments · Fixed by #183
Closed

Fix support for #![no_std] and serde #182

vic1707 opened this issue Sep 12, 2024 · 0 comments · Fixed by #183

Comments

@vic1707
Copy link
Contributor

vic1707 commented Sep 12, 2024

Unable to compile in #![no_std] when using serde feature is enable and std feature is disabled.
The issue happens only with Deserialize.
I think the issue is the use of std::marker in the gen_impl_trait_serde_deserialize function, I'll make some tests and a PR asap.

using

[package]
name = "ttt"
version = "0.0.0"
edition = "2021"

[dependencies]
nutype = { version = "0.5.0", default-features = false, features = ["serde"] }
serde = { version = "1.0.210", default-features = false }

and

#![no_std]
use nutype::nutype;

#[nutype(derive(Deserialize))]
struct A(f32);

I get

   Compiling ttt v0.0.0 (C:\Users\vic1707\Documents\Perso\ttt)
error[E0433]: failed to resolve: could not find `std` in the list of imported crates
 --> src\lib.rs:4:1
  |
4 | #[nutype(derive(Deserialize))]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ could not find `std` in the list of imported crates
  |
  = help: consider importing this module:
          core::marker
  = note: this error originates in the attribute macro `nutype` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0433`.
error: could not compile `ttt` (lib) due to 1 previous error

Whereas this works fine (after enabling the derive feature ofc).

#![no_std]
use serde::Deserialize;

#[derive(Deserialize)]
struct A(f32);
@vic1707 vic1707 changed the title Add support for #![no_std] and serde Fix support for #![no_std] and serde Sep 20, 2024
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

Successfully merging a pull request may close this issue.

1 participant