nit: nullptr is dead code, otherwise the above operator== would be UB. So if you retouch:
0os << "NoCopy(" << *o.m_n << ")";
Also: clang-format for me:
0diff --git a/src/test/result_tests.cpp b/src/test/result_tests.cpp
1index 847f68121d..6d688f7b74 100644
2--- a/src/test/result_tests.cpp
3+++ b/src/test/result_tests.cpp
4@@ -18,8 +18,7 @@ inline std::ostream& operator<<(std::ostream& os, const bilingual_str& s)
5
6 BOOST_AUTO_TEST_SUITE(result_tests)
7
8-struct NoCopy
9-{
10+struct NoCopy {
11 NoCopy(int n) : m_n{std::make_unique<int>(n)} {}
12 std::unique_ptr<int> m_n;
13 };
14@@ -31,7 +30,10 @@ bool operator==(const NoCopy& a, const NoCopy& b)
15
16 std::ostream& operator<<(std::ostream& os, const NoCopy& o)
17 {
18- if (o.m_n) os << "NoCopy(" << *o.m_n << ")"; else os << "NoCopy(nullptr)";
19+ if (o.m_n)
20+ os << "NoCopy(" << *o.m_n << ")";
21+ else
22+ os << "NoCopy(nullptr)";
23 return os;
24 }
25
26@@ -53,14 +55,14 @@ util::Result<NoCopy> NoCopyFn(int i, bool success)
27 return {util::Error{Untranslated(strprintf("nocopy %i error.", i))}};
28 }
29
30-template<typename T>
31+template <typename T>
32 void ExpectResult(const util::Result<T>& result, bool success, const bilingual_str& str)
33 {
34 BOOST_CHECK_EQUAL(bool(result), success);
35 BOOST_CHECK_EQUAL(util::ErrorString(result), str);
36 }
37
38-template<typename T, typename... Args>
39+template <typename T, typename... Args>
40 void ExpectSuccess(const util::Result<T>& result, const bilingual_str& str, Args&&... args)
41 {
42 ExpectResult(result, true, str);
43@@ -69,7 +71,7 @@ void ExpectSuccess(const util::Result<T>& result, const bilingual_str& str, Args
44 BOOST_CHECK_EQUAL(&result.value(), &*result);
45 }
46
47-template<typename T, typename... Args>
48+template <typename T, typename... Args>
49 void ExpectFail(const util::Result<T>& result, const bilingual_str& str)
50 {
51 ExpectResult(result, false, str);
52diff --git a/src/util/result.h b/src/util/result.h
53index 8f100b7933..a87627a589 100644
54--- a/src/util/result.h
55+++ b/src/util/result.h
56@@ -12,7 +12,9 @@
57
58 namespace util {
59
60-struct Error { bilingual_str message; };
61+struct Error {
62+ bilingual_str message;
63+};
64
65 //! The util::Result class provides a standard way for functions to return
66 //! either error messages or result values.
67@@ -29,8 +31,9 @@ struct Error { bilingual_str message; };
68 //! `std::optional<T>` can be updated to return `util::Result<T>` and return
69 //! error strings usually just replacing `return std::nullopt;` with `return
70 //! util::Error{error_string};`.
71-template<class T>
72-class Result {
73+template <class T>
74+class Result
75+{
76 private:
77 std::variant<bilingual_str, T> m_variant;
78
79@@ -44,17 +47,31 @@ public:
80 //! std::optional methods, so functions returning optional<T> can change to
81 //! return Result<T> with minimal changes to existing code, and vice versa.
82 bool has_value() const { return m_variant.index() == 1; }
83- const T& value() const LIFETIMEBOUND { assert(*this); return std::get<1>(m_variant); }
84- T& value() LIFETIMEBOUND { assert(*this); return std::get<1>(m_variant); }
85+ const T& value() const LIFETIMEBOUND
86+ {
87+ assert(*this);
88+ return std::get<1>(m_variant);
89+ }
90+ T& value() LIFETIMEBOUND
91+ {
92+ assert(*this);
93+ return std::get<1>(m_variant);
94+ }
95 explicit operator bool() const { return has_value(); }
96 const T* operator->() const LIFETIMEBOUND { return &value(); }
97 const T& operator*() const LIFETIMEBOUND { return value(); }
98 T* operator->() LIFETIMEBOUND { return &value(); }
99 T& operator*() LIFETIMEBOUND { return value(); }
100 template <class U>
101- T value_or(U&& default_value) const& { return has_value() ? value() : std::forward<U>(default_value); }
102+ T value_or(U&& default_value) const&
103+ {
104+ return has_value() ? value() : std::forward<U>(default_value);
105+ }
106 template <class U>
107- T value_or(U&& default_value) && { return has_value() ? std::move(value()) : std::forward<U>(default_value); }
108+ T value_or(U&& default_value) &&
109+ {
110+ return has_value() ? std::move(value()) : std::forward<U>(default_value);
111+ }
112 };
113
114 template <typename T>