Updated math lib and import in cargo toml file

This commit is contained in:
Sambo Chea 2020-08-20 16:02:30 +07:00
parent 0ae0b214bc
commit cc6b0c38db
5 changed files with 17 additions and 8 deletions

View File

@ -19,6 +19,8 @@ default = ["console_error_panic_hook"]
[dependencies]
wasm-bindgen = "0.2.63"
math = { path = "math", version = "0.1.0" }
# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for

View File

@ -1,9 +1,7 @@
mod math {
#[allow(dead_code)]
pub fn sum(a: i32, b: i32) -> i32 {
a + b
}
}
#[cfg(test)]
mod tests {
@ -11,6 +9,6 @@ mod tests {
#[test]
fn it_works() {
assert_eq!(math::sum(10, 10), 20);
assert_eq!(sum(10, 10), 20);
}
}

6
src/main.rs Normal file
View File

@ -0,0 +1,6 @@
use math;
fn main() {
let sum = math::sum(1, 2);
println!("Sum number {}", sum)
}

View File

@ -1,3 +1,4 @@
#[allow(dead_code)]
pub fn set_panic_hook() {
// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function at least once during initialization, and then

View File

@ -5,6 +5,8 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/math/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/math/target" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />