Unify the way that String construction and Vec indexing throw
diff --git a/src/cxx.cc b/src/cxx.cc
index da05ee2..0fa55b2 100644
--- a/src/cxx.cc
+++ b/src/cxx.cc
@@ -6,16 +6,6 @@
 #include <stdexcept>
 #include <vector>
 
-template <typename Exception>
-static void panic [[noreturn]] (const char *msg) {
-#if defined(RUST_CXX_NO_EXCEPTIONS)
-  std::cerr << "Error: " << msg << ". Aborting." << std::endl;
-  std::terminate();
-#else
-  throw Exception(msg);
-#endif
-}
-
 extern "C" {
 const char *cxxbridge03$cxx_string$data(const std::string &s) noexcept {
   return s.data();
@@ -42,6 +32,18 @@
 namespace rust {
 inline namespace cxxbridge03 {
 
+template <typename Exception>
+void panic [[noreturn]] (const char *msg) {
+#if defined(RUST_CXX_NO_EXCEPTIONS)
+  std::cerr << "Error: " << msg << ". Aborting." << std::endl;
+  std::terminate();
+#else
+  throw Exception(msg);
+#endif
+}
+
+template void panic<std::out_of_range>(const char *msg);
+
 String::String() noexcept { cxxbridge03$string$new(this); }
 
 String::String(const String &other) noexcept {