On Thu, Jan 5, 2017, at 03:28 PM, Cameron McCormack wrote: > On Tue, Dec 20, 2016, at 09:46 PM, Jan de Mooij wrote: > > A few weeks ago we added mozilla::Result<V, E> to MFBT [0][1]. I was > > asked > > to inform dev-platform about this, so here's a quick overview. > > mozilla::Result<V, E> is based on Rust's Result type [2]. It contains > > either a success value of type V or an error value of type E. > > I want to write a function that either returns an object that has > already been AddRefed or an nsresult error. > Result<already_AddRefed<...>, nsresult> doesn't seem to work. > Result<RefPtr<...>, nsresult> would presumably work, but might > wastefully touch the object's refcount. Is there a better way?
I think Result should change its constructors to support move-only things like already_AddRefed. Probably it can add a constructor which accepts T&& and Move it down the chain. I'm not sure what is the prefect way here, though. - Xidorn _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform