Bug 1319083 - Relax the Sized constraint on nsA[C]String::assign/append, r=froydnj
authorMichael Layzell <michael@thelayzells.com>
Sat, 19 Nov 2016 13:56:42 -0500
changeset 323596 bd8fc8fe4a9de47628c22ae1ed87cf9c9029acf8
parent 323595 ace6ae91b3760d36e66e9d831f30b4fba73c0c7a
child 323597 acf3c2497b43ad6537bfbbd91d23eaaa5302afca
push id84160
push usermichael@thelayzells.com
push dateMon, 21 Nov 2016 15:42:08 +0000
treeherdermozilla-inbound@bd8fc8fe4a9d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1319083
milestone53.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 1319083 - Relax the Sized constraint on nsA[C]String::assign/append, r=froydnj MozReview-Commit-ID: Js5GOrnqtsg
xpcom/rust/nsstring/src/lib.rs
--- a/xpcom/rust/nsstring/src/lib.rs
+++ b/xpcom/rust/nsstring/src/lib.rs
@@ -567,36 +567,36 @@ define_string_types! {
 impl nsACString {
     /// Leaves the nsACString in an unstable state with a dangling data pointer.
     /// Should only be used in drop implementations of rust types which wrap
     /// this type.
     unsafe fn finalize(&mut self) {
         Gecko_FinalizeCString(self);
     }
 
-    pub fn assign<T: AsRef<[u8]>>(&mut self, other: &T) {
+    pub fn assign<T: AsRef<[u8]> + ?Sized>(&mut self, other: &T) {
         let s = nsCString::from(other.as_ref());
         unsafe {
             Gecko_AssignCString(self, &*s);
         }
     }
 
-    pub fn assign_utf16<T: AsRef<[u16]>>(&mut self, other: &T) {
+    pub fn assign_utf16<T: AsRef<[u16]> + ?Sized>(&mut self, other: &T) {
         self.assign(&[]);
         self.append_utf16(other);
     }
 
-    pub fn append<T: AsRef<[u8]>>(&mut self, other: &T) {
+    pub fn append<T: AsRef<[u8]> + ?Sized>(&mut self, other: &T) {
         let s = nsCString::from(other.as_ref());
         unsafe {
             Gecko_AppendCString(self, &*s);
         }
     }
 
-    pub fn append_utf16<T: AsRef<[u16]>>(&mut self, other: &T) {
+    pub fn append_utf16<T: AsRef<[u16]> + ?Sized>(&mut self, other: &T) {
         let s = nsString::from(other.as_ref());
         unsafe {
             Gecko_AppendUTF16toCString(self, &*s);
         }
     }
 
     pub unsafe fn as_str_unchecked(&self) -> &str {
         str::from_utf8_unchecked(self)
@@ -674,36 +674,36 @@ define_string_types! {
 impl nsAString {
     /// Leaves the nsAString in an unstable state with a dangling data pointer.
     /// Should only be used in drop implementations of rust types which wrap
     /// this type.
     unsafe fn finalize(&mut self) {
         Gecko_FinalizeString(self);
     }
 
-    pub fn assign<T: AsRef<[u16]>>(&mut self, other: &T) {
+    pub fn assign<T: AsRef<[u16]> + ?Sized>(&mut self, other: &T) {
         let s = nsString::from(other.as_ref());
         unsafe {
             Gecko_AssignString(self, &*s);
         }
     }
 
-    pub fn assign_utf8<T: AsRef<[u8]>>(&mut self, other: &T) {
+    pub fn assign_utf8<T: AsRef<[u8]> + ?Sized>(&mut self, other: &T) {
         self.assign(&[]);
         self.append_utf8(other);
     }
 
-    pub fn append<T: AsRef<[u16]>>(&mut self, other: &T) {
+    pub fn append<T: AsRef<[u16]> + ?Sized>(&mut self, other: &T) {
         let s = nsString::from(other.as_ref());
         unsafe {
             Gecko_AppendString(self, &*s);
         }
     }
 
-    pub fn append_utf8<T: AsRef<[u8]>>(&mut self, other: &T) {
+    pub fn append_utf8<T: AsRef<[u8]> + ?Sized>(&mut self, other: &T) {
         let s = nsCString::from(other.as_ref());
         unsafe {
             Gecko_AppendUTF8toString(self, &*s);
         }
     }
 }
 
 // NOTE: The From impl for a string slice for nsString produces a <'static>