diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..181605d5 --- /dev/null +++ b/.clang-format @@ -0,0 +1 @@ +AlwaysBreakTemplateDeclarations: true diff --git a/include/cxx.h b/include/cxx.h index f7decd80..a8239a12 100644 --- a/include/cxx.h +++ b/include/cxx.h @@ -85,7 +85,8 @@ private: #ifndef CXXBRIDGE02_RUST_BOX #define CXXBRIDGE02_RUST_BOX -template class Box final { +template +class Box final { public: using value_type = T; using const_pointer = typename std::add_pointer< @@ -132,7 +133,8 @@ public: T *operator->() noexcept { return this->ptr; } T &operator*() noexcept { return *this->ptr; } - template static Box in_place(Fields &&... fields) { + template + static Box in_place(Fields &&... fields) { Box box; box.uninit(); ::new (box.ptr) T{std::forward(fields)...}; @@ -163,7 +165,8 @@ private: #ifndef CXXBRIDGE02_RUST_FN #define CXXBRIDGE02_RUST_FN -template class Fn; +template +class Fn; template class Fn { @@ -176,7 +179,8 @@ private: void *fn; }; -template using TryFn = Fn; +template +using TryFn = Fn; #endif // CXXBRIDGE02_RUST_FN #ifndef CXXBRIDGE02_RUST_ERROR @@ -209,11 +213,13 @@ std::ostream &operator<<(std::ostream &, const Str &); // Snake case aliases for use in code that uses this style for type names. using string = String; using str = Str; -template using box = Box; +template +using box = Box; using error = Error; template using fn = Fn; -template using try_fn = TryFn; +template +using try_fn = TryFn; #ifndef CXXBRIDGE02_RUST_BITCOPY #define CXXBRIDGE02_RUST_BITCOPY diff --git a/src/cxx.cc b/src/cxx.cc index e8ec979d..b64333c7 100644 --- a/src/cxx.cc +++ b/src/cxx.cc @@ -5,7 +5,8 @@ #include #include -template static void panic [[noreturn]] (const char *msg) { +template +static void panic [[noreturn]] (const char *msg) { #if defined(RUST_CXX_NO_EXCEPTIONS) std::cerr << "Error: " << msg << ". Aborting." << std::endl; std::terminate();