From 628aa6a630b17d1c2ecde537cc452186f9d90725 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 4 Apr 2018 11:24:56 -0700 Subject: [PATCH] Add an into_repr on the nsstring bindings. I didn't end up using this, but mystor reviewed it and it's useful. MozReview-Commit-ID: 5LNzCEGpbLy --- support/gecko/nsstring/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/support/gecko/nsstring/src/lib.rs b/support/gecko/nsstring/src/lib.rs index 8cb8d11ce7e..02352212938 100644 --- a/support/gecko/nsstring/src/lib.rs +++ b/support/gecko/nsstring/src/lib.rs @@ -559,6 +559,12 @@ macro_rules! define_string_types { hdr: $StringRepr::new(ClassFlags::NULL_TERMINATED), } } + + /// Converts this String into a StringRepr, which will leak if the + /// repr is not passed to something that knows how to free it. + pub fn into_repr(mut self) -> $StringRepr { + mem::replace(&mut self.hdr, $StringRepr::new(ClassFlags::NULL_TERMINATED)) + } } impl Drop for $String {