Skip to content

Commit

Permalink
start of rust implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
milesgranger committed Oct 19, 2017
1 parent a208c57 commit f56bd8e
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 0 deletions.
170 changes: 170 additions & 0 deletions rust_gap/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions rust_gap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "gap-stat"
version = "0.1.0"
authors = ["Miles Granger <miles59923@gmail.com>"]

[dependencies]
pyo3 = { version = "0.2", features = ["extension-module"] }

[lib]
name = "rust2py"
crate-type = ["cdylib"]
20 changes: 20 additions & 0 deletions rust_gap/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#![feature(proc_macro, specialization)]

extern crate pyo3;
use pyo3::prelude::*;


#[py::modinit(rust_gap)]
fn init_mod(py: Python, m: &PyModule) -> PyResult<()> {

#[pyfn(m, "sum_as_string")]
fn sum_as_string_py(a: i64, b: i64) -> PyResult<String> {
let out = sum_as_string(a, b);
Ok(out)
}
Ok(())
}

fn sum_as_string(a: i64, b: i64) -> String {
format!("{}", a + b).to_string()
}

0 comments on commit f56bd8e

Please sign in to comment.