Closed Bug 1313160 Opened 8 years ago Closed 8 years ago

Add ::From<&'a String> conversion to nsString rust library

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: qdot, Assigned: qdot)

Details

Attachments

(1 file)

Currently, in the nsString rust library, we have to reference a slice explicitly to convert a rust String type to ns[C]String. Being able to go from rust String -> ns[C]String directly would be slightly more succinct and should only require an extra From trait overload.
Just handles explicit String -> str conversion before letting str From implementation do the work.
Assignee: nobody → kyle
Attachment #8805240 - Flags: review?(michael)
Comment on attachment 8805240 [details] [diff] [review]
Patch 1 (v1) - Add conveinence ::From<&'a String> conversion for rust nsstring types

Review of attachment 8805240 [details] [diff] [review]:
-----------------------------------------------------------------

The whole String vs $String thing is a bit ugly, but that's my fault and completely outside of the scope of this patch. LGTM.

Only other thought I have is to consider also adding `impl<'a> From<&'a Vec<$char_t>> for $String<'a> {}` in a similar manner, just for consistency between String &str and Vec<u8> &[u8]. We can do that somewhere else though *shrug*.
Attachment #8805240 - Flags: review?(michael) → review+
Pushed by kmachulis@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/46acc3239275
Add From<&'a String> and From<&'a Vec<u8>> conversions for rust nsstring lib; r=mystor
https://hg.mozilla.org/mozilla-central/rev/46acc3239275
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
You need to log in before you can comment on or make changes to this bug.