Closed
Bug 1482828
Opened 8 years ago
Closed 8 years ago
Introduce C++ analogs of Rust's nsA[C]StringBulkWriteHandle
Categories
(Core :: XPCOM, enhancement)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla63
| Tracking | Status | |
|---|---|---|
| firefox63 | --- | fixed |
People
(Reporter: hsivonen, Assigned: hsivonen)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
Starting a bulk write on an nsA[C]String in Rust gives you a RAII handle that puts the string in a valid state in case an error causes an early return before the bulk write is successfully finished. Rust's borrow system also prevents access to the string by other means while the bulk write remains unfinished.
C++ can't replicate the latter point, but it can replicate the former point about handling early returns before successful bulk write finish. We could introduce C++ RAII types (for nsAString and nsACString) that take care of this.
| Assignee | ||
Comment 1•8 years ago
|
||
I failed to figure out how mozilla::BulkWriteHandle, which is supposed to have move semantics, can be used as the success type wrapped in mozilla::Result. Is it possible? How?
https://phabricator.services.mozilla.com/D3405#inline-12152
Flags: needinfo?(nfroyd)
Comment 2•8 years ago
|
||
I guess you encountered some sort of compilation error? It's hard to say what the problem is without further details about the error. I did file bug 1418624 about some replacement/addition for Result::unwrap which is friendlier to move-only types, which I think might address your concern?
Flags: needinfo?(nfroyd)
| Assignee | ||
Comment 3•8 years ago
|
||
(In reply to Nathan Froyd [:froydnj] from comment #2)
> I guess you encountered some sort of compilation error?
Yes. mozilla::Result wants a copy constructor and the compiler tells me I've deleted it.
> I did file bug
> 1418624 about some replacement/addition for Result::unwrap which is
> friendlier to move-only types, which I think might address your concern?
Thanks. It looks like I can't use mozilla::Result for this until that bug is fixed. :-(
I'll use an outparam for error.
| Assignee | ||
Comment 4•8 years ago
|
||
MozReview-Commit-ID: BZyHd4VzNur
| Assignee | ||
Comment 5•8 years ago
|
||
Let's see that it actually compiles on all platforms:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=c6aef12e0030b153224631562a08f3998499f196
Comment 6•8 years ago
|
||
Comment on attachment 9001235 [details]
Bug 1482828 - Introduce C++ analogs of Rust's nsA[C]StringBulkWriteHandle.
Nathan Froyd [:froydnj] has approved the revision.
Attachment #9001235 -
Flags: review+
Pushed by hsivonen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/400d4a90fe04
Introduce C++ analogs of Rust's nsA[C]StringBulkWriteHandle. r=froydnj
Comment 8•8 years ago
|
||
| bugherder | ||
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox63:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
Updated•5 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•