Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
mod is a child module/namespace
declaration. There are 2 ways to declare it - via a block and via a separate file:
// через блок
mod some_module {
// тут изолированное пространство имен
pub fn hello() {
println!("Hello world");
}
}
fn main() {
some_module::hello(); // Hello world
}
// подключаем модуль из файла ./some_other_module/mod.rs или ./some_other_module.rs
mod some_other_module;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question