Created
June 22, 2022 19:32
-
-
Save kriogenia/45fb371eaaee66ad33b47623646ca061 to your computer and use it in GitHub Desktop.
Using mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod calc; | |
mod foo; | |
fn main() { | |
assert!(foo::bar()); | |
assert_eq!(2, calc::mul::mul(2, calc::mul::MUL_IDENTITY)); | |
println!("{}", calc::hello()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub mod mul; | |
mod strings; // Hidden to the outside world | |
pub fn hello() -> &'static str { | |
strings::HELLO | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub const MUL_IDENTITY: usize = 1; | |
pub fn mul<T: std::ops::Mul<Output = T>>(left: T, right: T) -> T { | |
left * right | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub const HELLO: &'static str = "Hello Math World!"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment