removed std from serialize implementation in rust Vector type
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.
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.
I know very little about rust, but stumbling through it this seems like a safe change -- if I'm reading correctly, this will not affect any current users, just unblocks no_std?
Is there any existing test infrastructure that would help us catch this or any other regressions in the future?
I would also be curious as to how this PR relates to #8565