Move writing includes to write.rs
diff --git a/gen/src/include.rs b/gen/src/include.rs
index 309d8c3..b49cf82 100644
--- a/gen/src/include.rs
+++ b/gen/src/include.rs
@@ -1,6 +1,5 @@
 use crate::gen::out::OutFile;
 use crate::syntax::{self, IncludeKind};
-use std::fmt::{self, Display};
 
 /// The complete contents of the "rust/cxx.h" header.
 pub static HEADER: &str = include_str!("include/cxx.h");
@@ -64,7 +63,7 @@
 
 #[derive(Default, PartialEq)]
 pub struct Includes {
-    custom: Vec<Include>,
+    pub custom: Vec<Include>,
     pub array: bool,
     pub cstddef: bool,
     pub cstdint: bool,
@@ -103,57 +102,3 @@
         }
     }
 }
-
-impl Display for Includes {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        for include in &self.custom {
-            match include.kind {
-                IncludeKind::Quoted => {
-                    writeln!(f, "#include \"{}\"", include.path.escape_default())?;
-                }
-                IncludeKind::Bracketed => {
-                    writeln!(f, "#include <{}>", include.path)?;
-                }
-            }
-        }
-        if self.array {
-            writeln!(f, "#include <array>")?;
-        }
-        if self.cstddef {
-            writeln!(f, "#include <cstddef>")?;
-        }
-        if self.cstdint {
-            writeln!(f, "#include <cstdint>")?;
-        }
-        if self.cstring {
-            writeln!(f, "#include <cstring>")?;
-        }
-        if self.exception {
-            writeln!(f, "#include <exception>")?;
-        }
-        if self.memory {
-            writeln!(f, "#include <memory>")?;
-        }
-        if self.new {
-            writeln!(f, "#include <new>")?;
-        }
-        if self.string {
-            writeln!(f, "#include <string>")?;
-        }
-        if self.type_traits {
-            writeln!(f, "#include <type_traits>")?;
-        }
-        if self.utility {
-            writeln!(f, "#include <utility>")?;
-        }
-        if self.vector {
-            writeln!(f, "#include <vector>")?;
-        }
-        if self.basetsd {
-            writeln!(f, "#if defined(_WIN32)")?;
-            writeln!(f, "#include <basetsd.h>")?;
-            writeln!(f, "#endif")?;
-        }
-        Ok(())
-    }
-}
diff --git a/gen/src/write.rs b/gen/src/write.rs
index 0514554..9a1331e 100644
--- a/gen/src/write.rs
+++ b/gen/src/write.rs
@@ -1,11 +1,12 @@
+use crate::gen::include::{self, Includes};
 use crate::gen::namespace_organizer::NamespaceEntries;
-use crate::gen::out::OutFile;
-use crate::gen::{include, Opt};
+use crate::gen::out::{Content, OutFile};
+use crate::gen::Opt;
 use crate::syntax::atom::Atom::{self, *};
 use crate::syntax::symbol::Symbol;
 use crate::syntax::{
-    mangle, Api, CppName, Enum, ExternFn, ExternType, ResolvableName, Signature, Struct, Type,
-    Types, Var,
+    mangle, Api, CppName, Enum, ExternFn, ExternType, IncludeKind, ResolvableName, Signature,
+    Struct, Type, Types, Var,
 };
 use proc_macro2::Ident;
 use std::collections::HashMap;
@@ -40,7 +41,7 @@
         write_generic_instantiations(out);
     }
 
-    write!(out.front, "{}", out.include);
+    write_includes(&mut out.front, &out.include);
 
     out_file
 }
@@ -247,6 +248,58 @@
     }
 }
 
+fn write_includes(out: &mut Content, include: &Includes) {
+    for include in &include.custom {
+        match include.kind {
+            IncludeKind::Quoted => {
+                writeln!(out, "#include \"{}\"", include.path.escape_default());
+            }
+            IncludeKind::Bracketed => {
+                writeln!(out, "#include <{}>", include.path);
+            }
+        }
+    }
+
+    if include.array {
+        writeln!(out, "#include <array>");
+    }
+    if include.cstddef {
+        writeln!(out, "#include <cstddef>");
+    }
+    if include.cstdint {
+        writeln!(out, "#include <cstdint>");
+    }
+    if include.cstring {
+        writeln!(out, "#include <cstring>");
+    }
+    if include.exception {
+        writeln!(out, "#include <exception>");
+    }
+    if include.memory {
+        writeln!(out, "#include <memory>");
+    }
+    if include.new {
+        writeln!(out, "#include <new>");
+    }
+    if include.string {
+        writeln!(out, "#include <string>");
+    }
+    if include.type_traits {
+        writeln!(out, "#include <type_traits>");
+    }
+    if include.utility {
+        writeln!(out, "#include <utility>");
+    }
+    if include.vector {
+        writeln!(out, "#include <vector>");
+    }
+    if include.basetsd {
+        writeln!(out, "#if defined(_WIN32)");
+        writeln!(out, "#include <basetsd.h>");
+        writeln!(out, "#endif");
+    }
+}
+
 fn write_builtins(out: &mut OutFile) {
     out.begin_block("namespace rust");
     out.begin_block("inline namespace cxxbridge05");