Modules
impl
๋ธ๋ก์ ๋ค์์คํ์ด์คํจ์๋ฅผ ํ์
์ผ๋ก ์ ๊ณตํฉ๋๋ค. mod
์ญ์ ๋ค์์คํ์ด์ค ํ์
๊ณผ ํจ์๋ฅผ ์ ๊ณตํฉ๋๋ค:
We have seen how
impl
blocks let us namespace functions to a type. Similarly,mod
lets us namespace types and functions:
mod foo { pub fn do_something() { println!("In the foo module"); } } mod bar { pub fn do_something() { println!("In the bar module"); } } fn main() { foo::do_something(); bar::do_something(); }