Bug 1530438 - Implement Clone for the rust nsString bindings, r=froydnj
authorNika Layzell <nika@thelayzells.com>
Mon, 25 Feb 2019 18:32:00 +0000
changeset 518841 959aa87abd32bbab3b094cf01939e5569ac3245c
parent 518840 f100f8631f78c50427ecd50f0dee4009d06ca4e1
child 518842 22436d124e3a4025a0a1497572bc741dfc8350fe
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1530438
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1530438 - Implement Clone for the rust nsString bindings, r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D21039
xpcom/rust/nsstring/src/lib.rs
--- a/xpcom/rust/nsstring/src/lib.rs
+++ b/xpcom/rust/nsstring/src/lib.rs
@@ -885,16 +885,24 @@ macro_rules! define_string_types {
         }
 
         impl DerefMut for $String {
             fn deref_mut(&mut self) -> &mut $AString {
                 &mut self.hdr
             }
         }
 
+        impl Clone for $String {
+            fn clone(&self) -> Self {
+                let mut copy = $String::new();
+                copy.assign(self);
+                copy
+            }
+        }
+
         impl AsRef<[$char_t]> for $String {
             fn as_ref(&self) -> &[$char_t] {
                 &self
             }
         }
 
         impl<'a> From<&'a [$char_t]> for $String {
             fn from(s: &'a [$char_t]) -> $String {