diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp index cece22120..0369188d1 100644 --- a/src/idl_gen_rust.cpp +++ b/src/idl_gen_rust.cpp @@ -1786,14 +1786,17 @@ class RustGenerator : public BaseGenerator { void GenNamespaceImports(const int white_spaces) { std::string indent = std::string(white_spaces, ' '); code_ += ""; - for (auto it = parser_.included_files_.begin(); - it != parser_.included_files_.end(); ++it) { - if (it->second.empty()) continue; - auto noext = flatbuffers::StripExtension(it->second); - auto basename = flatbuffers::StripPath(noext); + if (!parser_.opts.generate_all) { + for (auto it = parser_.included_files_.begin(); + it != parser_.included_files_.end(); ++it) { + if (it->second.empty()) continue; + auto noext = flatbuffers::StripExtension(it->second); + auto basename = flatbuffers::StripPath(noext); - code_ += indent + "use crate::" + basename + "_generated::*;"; + code_ += indent + "use crate::" + basename + "_generated::*;"; + } } + code_ += indent + "use std::mem;"; code_ += indent + "use std::cmp::Ordering;"; code_ += "";