Bug 1563065: Use const& in mozilla::Result constructors. r=froydnj

Change the `ResultImplementation` and `Result` constructors to accept success
values by `const` reference. This makes it possible for `Result` to carry
`MOZ_NON_PARAM` types as success values.

Differential Revision: https://phabricator.services.mozilla.com/D36682

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jim Blandy 2019-07-05 23:50:16 +00:00
Родитель 8039da4d93
Коммит 45737ac244
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -47,7 +47,7 @@ class ResultImplementation<V, E, PackingStrategy::Variant> {
mozilla::Variant<V, E> mStorage;
public:
explicit ResultImplementation(V aValue) : mStorage(aValue) {}
explicit ResultImplementation(const V& aValue) : mStorage(aValue) {}
explicit ResultImplementation(E aErrorValue) : mStorage(aErrorValue) {}
bool isOk() const { return mStorage.template is<V>(); }
@ -68,7 +68,7 @@ class ResultImplementation<V, E&, PackingStrategy::Variant> {
mozilla::Variant<V, E*> mStorage;
public:
explicit ResultImplementation(V aValue) : mStorage(aValue) {}
explicit ResultImplementation(const V& aValue) : mStorage(aValue) {}
explicit ResultImplementation(E& aErrorValue) : mStorage(&aErrorValue) {}
bool isOk() const { return mStorage.template is<V>(); }
@ -300,7 +300,7 @@ class MOZ_MUST_USE_TYPE Result final {
/**
* Create a success result.
*/
MOZ_IMPLICIT Result(V aValue) : mImpl(aValue) { MOZ_ASSERT(isOk()); }
MOZ_IMPLICIT Result(const V& aValue) : mImpl(aValue) { MOZ_ASSERT(isOk()); }
/**
* Create an error result.