From 9cbc4393eb61bfe46ef1d8868a0ab32fa64c0985 Mon Sep 17 00:00:00 2001 From: Alan Jeffrey Date: Tue, 10 Nov 2015 15:18:37 -0600 Subject: [PATCH] Added conversion functions between DOMString and String. Implemented From and From<&str> for DOMString, and From for String. --- components/util/str.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/components/util/str.rs b/components/util/str.rs index 9544e1d025e..7606cde47a4 100644 --- a/components/util/str.rs +++ b/components/util/str.rs @@ -79,6 +79,24 @@ impl<'a> PartialEq<&'a str> for DOMString { } } +impl From for DOMString { + fn from(contents: String) -> DOMString { + DOMString(contents) + } +} + +impl<'a> From<&'a str> for DOMString { + fn from(contents: &str) -> DOMString { + DOMString::from(String::from(contents)) + } +} + +impl From for String { + fn from(contents: DOMString) -> String { + contents.0 + } +} + impl Into> for DOMString { fn into(self) -> Vec { self.0.into()