webdriver: Add From<T> for WebElement where T: Into<String>
authorJames Graham <james@hoppipolla.co.uk>
Fri, 27 May 2016 15:46:20 +0100
changeset 428067 1f47d6c22fc42cea640ce46820709014a04a3c30
parent 428066 38e9963f1d7d69f80aca8715a88778c10e0a00a2
child 428068 acada1c3d717f0e4b2f57c8bbe571e1d70fa3434
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone57.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
webdriver: Add From<T> for WebElement where T: Into<String> Source-Repo: https://github.com/mozilla/webdriver-rust Source-Revision: edae38aa835e2ba5c40c819ae47d798ee08cac1e
testing/webdriver/src/common.rs
--- a/testing/webdriver/src/common.rs
+++ b/testing/webdriver/src/common.rs
@@ -85,17 +85,17 @@ impl<T: ToJson> Into<Option<T>> for Null
     fn into(self) -> Option<T> {
         match self {
             Nullable::Value(val) => Some(val),
             Nullable::Null => None
         }
     }
 }
 
-#[derive(PartialEq, Debug)]
+#[derive(Clone, Debug, PartialEq)]
 pub struct WebElement {
     pub id: String
 }
 
 impl WebElement {
     pub fn new(id: String) -> WebElement {
         WebElement {
             id: id
@@ -121,16 +121,23 @@ impl WebElement {
 impl ToJson for WebElement {
     fn to_json(&self) -> Json {
         let mut data = BTreeMap::new();
         data.insert(ELEMENT_KEY.to_string(), self.id.to_json());
         Json::Object(data)
     }
 }
 
+impl <T> From<T> for WebElement
+    where T: Into<String> {
+    fn from(data: T) -> WebElement {
+        WebElement::new(data.into())
+    }
+}
+
 #[derive(PartialEq, Debug)]
 pub enum FrameId {
     Short(u16),
     Element(WebElement),
     Null
 }
 
 impl FrameId {