2019-02-06 08:57:13 -05:00
|
|
|
#![feature(specialization)]
|
|
|
|
|
|
|
|
#[macro_use] extern crate pyo3;
|
|
|
|
|
|
|
|
use pyo3::prelude::*;
|
|
|
|
|
|
|
|
|
|
|
|
#[pyfunction]
|
2019-02-04 09:05:11 -05:00
|
|
|
fn convert_celsius_to_fahrenheit(celsius: f32) -> f32 {
|
|
|
|
celsius * 1.8 + 32.0
|
|
|
|
}
|
|
|
|
|
2019-02-06 08:57:13 -05:00
|
|
|
#[pymodule]
|
|
|
|
fn unit_converter(_py: Python, m: &PyModule) -> PyResult<()> {
|
|
|
|
m.add_wrapped(wrap_pyfunction!(convert_celsius_to_fahrenheit))?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2019-02-01 08:41:54 -05:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2019-02-04 09:05:11 -05:00
|
|
|
|
|
|
|
use super::convert_celsius_to_fahrenheit;
|
|
|
|
|
2019-02-01 08:41:54 -05:00
|
|
|
#[test]
|
2019-02-04 09:05:11 -05:00
|
|
|
fn conversion_celsius_to_fahrenheit() {
|
|
|
|
assert_eq!(convert_celsius_to_fahrenheit(25.0), 77.0);
|
2019-02-01 08:41:54 -05:00
|
|
|
}
|
2019-02-06 08:17:16 -05:00
|
|
|
}
|