Skip to content

Serde and no_std #8

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

Closed
sffc opened this issue Jun 30, 2020 · 3 comments
Closed

Serde and no_std #8

sffc opened this issue Jun 30, 2020 · 3 comments

Comments

@sffc
Copy link

sffc commented Jun 30, 2020

One more thing:

I added a smallstr dependency to my no_std project as so:

[dependencies.smallstr]
version = "0.2.0"
default-features = false
features = ["serde"]
git = "https://github.com/murarth/smallstr"

It gets further than it did before #7, but now it gets stuck on:

error[E0407]: method `visit_string` is not a member of trait `Visitor`
   --> /home/sffc/.cargo/git/checkouts/smallstr-93667b6dc37af95b/68efc08/src/string.rs:529:5
    |
529 | /     fn visit_string<E: Error>(self, v: String) -> Result<Self::Value, E> {
530 | |         Ok(v.into())
531 | |     }
    | |_____^ not a member of trait `Visitor`

error: aborting due to previous error

Here's the definition in Serde:

https://docs.serde.rs/src/serde/de/mod.rs.html#1508

    #[inline]
    #[cfg(any(feature = "std", feature = "alloc"))]
    fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
    where
        E: Error,
    {
        self.visit_str(&v)
    }

Should you give the alloc feature to serde, since I think SmallVec already uses alloc in no_std?

@murarth
Copy link
Owner

murarth commented Jun 30, 2020

I've just pushed a commit that should resolve this issue.

This should have been caught in testing, but it seems that Cargo is not honoring default-features = false when building from the smallstr project. It seems related to this issue: rust-lang/cargo#8366

@sffc
Copy link
Author

sffc commented Jul 1, 2020

Thank you! Confirmed that smallstr works now when installed from c28b751 in both std and no_std with the serde dependency. 👍

@sffc sffc closed this as completed Jul 1, 2020
@appetrosyan
Copy link

Now that 0.3.0 is available, the latest upstream also works with serde and no_std.

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

3 participants