]> git.lizzy.rs Git - rust.git/blobdiff - example/mini_core.rs
Pass command-line arguments to JITed function
[rust.git] / example / mini_core.rs
index 4da661ebb8d863fd76e8808801e246e13fad1713..b7277f5ee9f489867bedf15f32be363c47ccbd5a 100644 (file)
@@ -104,6 +104,14 @@ fn mul(self, rhs: Self) -> Self::Output {
     }
 }
 
+impl Mul for usize {
+    type Output = Self;
+
+    fn mul(self, rhs: Self) -> Self::Output {
+        self * rhs
+    }
+}
+
 #[lang = "add"]
 pub trait Add<RHS = Self> {
     type Output;
@@ -208,6 +216,15 @@ fn ne(&self, other: &usize) -> bool {
     }
 }
 
+impl PartialEq for isize {
+    fn eq(&self, other: &isize) -> bool {
+        (*self) == (*other)
+    }
+    fn ne(&self, other: &isize) -> bool {
+        (*self) != (*other)
+    }
+}
+
 impl PartialEq for char {
     fn eq(&self, other: &char) -> bool {
         (*self) == (*other)
@@ -338,7 +355,7 @@ pub mod libc {
     #[link(name = "c")]
     extern "C" {
         pub fn puts(s: *const u8);
-        pub fn printf(format: *const char, ...) -> i32;
+        pub fn printf(format: *const i8, ...) -> i32;
         pub fn malloc(size: usize) -> *mut u8;
         pub fn free(ptr: *mut u8);
         pub fn memcpy(dst: *mut u8, src: *const u8, size: usize);