Skip to content

Conversation

@lvboudre
Copy link

What

In no_std environment:

flatbuffers = { version = "25.9.23",  default-features = false, features = ["serialization"] }

The Vector type implements serde::ser::Serialize's serialize function by returning std::result::Result instead of core::result::Result, which cause the following type error:

--> /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/flatbuffers-25.9.23/src/array.rs:152:46
    |
152 |     fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    |                                              ^^^ use of unresolved module or unlinked crate `std`
    |
    = help: if you wanted to use a crate named `std`, use `cargo add std` to add it to your `Cargo.toml`
help: consider importing this module
    |
17  + use core::result;
    |
help: if you import `result`, refer to it directly
    |
152 -     fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
152 +     fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
    |

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `std`
   --> /usr/local/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/flatbuffers-25.9.23/src/vector.rs:321:46
    |
321 |     fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    |                                              ^^^ use of unresolved module or unlinked crate `std`
    |
    = help: if you wanted to use a crate named `std`, use `cargo add std` to add it to your `Cargo.toml`
help: consider importing this module
    |
17  + use core::result;
    |
help: if you import `result`, refer to it directly
    |
321 -     fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
321 +     fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
    |

This pr remove the std::result for core::result to allow serde in no_std environment.

@google-cla
Copy link

google-cla bot commented Oct 31, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added the rust label Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant