@@ -60,8 +60,7 @@ use std::rc::Rc;
6060)" );
6161}
6262
63- std::string Converter::EmitMethodsOnPtr () {
64- std::string out;
63+ void Converter::EmitMethodsOnPtr (std::string &out) {
6564 for (const auto &[name, methods] : methods_on_ptr_) {
6665 out += methods.trait_header ;
6766 out += " {\n " ;
@@ -72,35 +71,30 @@ std::string Converter::EmitMethodsOnPtr() {
7271 out += methods.impl_body ;
7372 out += " }\n " ;
7473 }
75- return out;
7674}
7775
7876std::string Converter::ForceGlobalInit (const clang::VarDecl *decl) {
7977 return std::format (" std::cell::LazyCell::force(&*&raw const {});" ,
8078 GetNamedDeclAsString (decl));
8179}
8280
83- std::string Converter::EmitGlobalInits (Model model) {
84- std::string out = model == Model::kUnsafe
85- ? " pub unsafe fn __cpp2rust_init_globals() {\n "
86- : " pub fn __cpp2rust_init_globals() {\n " ;
81+ void Converter::EmitGlobalInits (Model model, string &out) {
82+ out += model == Model::kUnsafe ? " pub unsafe fn __cpp2rust_init_globals() {\n "
83+ : " pub fn __cpp2rust_init_globals() {\n " ;
8784 for (const auto &line : global_inits_) {
8885 out += line;
8986 out += ' \n ' ;
9087 }
9188 out += " }\n " ;
92- return out;
9389}
9490
95- std::string Converter::EmitOpaqueRecords () {
96- std::string out;
91+ void Converter::EmitOpaqueRecords (std::string &out) {
9792 record_decls_.ForEachUndefined ([&](const std::string &name) {
9893 out += " #[derive(Clone, Copy, Default, ByteRepr)]" ;
9994 out += " pub struct " ;
10095 out += name;
10196 out += " ;\n " ;
10297 });
103- return out;
10498}
10599
106100bool Converter::VisitRecoveryExpr (clang::RecoveryExpr *expr) {
0 commit comments