]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
initial test rust code t1
authorRamakrishnan Muthukrishnan <ram@leastauthority.com>
Fri, 17 Feb 2023 09:41:11 +0000 (15:11 +0530)
committerRamakrishnan Muthukrishnan <ram@rkrishnan.org>
Wed, 9 Aug 2023 13:35:31 +0000 (19:05 +0530)
rust/Cargo.toml [new file with mode: 0644]
rust/src/lib.rs [new file with mode: 0644]

diff --git a/rust/Cargo.toml b/rust/Cargo.toml
new file mode 100644 (file)
index 0000000..48363f2
--- /dev/null
@@ -0,0 +1,12 @@
+[package]
+name = "hpsdr"
+version = "0.1.0"
+edition = "2021"
+authors = ["Ramakrishnan Muthukrishnan <ram@rkrishnan.org>"]
+
+[dependencies]
+libc = "0.2"
+
+[lib]
+name = "hpsdr"
+crate-type = ["staticlib"]
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
new file mode 100644 (file)
index 0000000..5d7f64a
--- /dev/null
@@ -0,0 +1,17 @@
+use libc::{size_t};
+
+#[no_mangle]
+pub extern fn add(left: size_t, right: size_t) -> size_t {
+    left + right
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn it_works() {
+        let result = add(2, 2);
+        assert_eq!(result, 4);
+    }
+}