]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_llvm/value.rs
Generalized base.rs#call_memcpy and everything that it uses
[rust.git] / src / librustc_codegen_llvm / value.rs
index 3328948c2951e5ce18e8b500b4ce9e1189c7f6a9..1b789f67b57b9c0c0cfd8d70d03699293d0459d7 100644 (file)
 use std::fmt;
 use std::hash::{Hash, Hasher};
 
+pub trait ValueTrait: fmt::Debug {
+    fn to_llvm(&self) -> &llvm::Value;
+    fn of_llvm(&llvm::Value) -> &Self;
+}
+
 impl PartialEq for Value {
     fn eq(&self, other: &Self) -> bool {
         self as *const _ == other as *const _
     }
 }
 
+impl ValueTrait for Value {
+    fn to_llvm(&self) -> &llvm::Value {
+        &self
+    }
+    fn of_llvm(v: &llvm::Value) -> &Self {
+        &v
+    }
+}
+
 impl Eq for Value {}
 
 impl Hash for Value {
@@ -34,6 +48,6 @@ impl fmt::Debug for Value {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.write_str(&llvm::build_string(|s| unsafe {
             llvm::LLVMRustWriteValueToString(self, s);
-        }).expect("nun-UTF8 value description from LLVM"))
+        }).expect("non-UTF8 value description from LLVM"))
     }
 }