如何从 Rust 中的模块导入单个函数?

How can I import a single function from a module in Rust?

我是 Rust 的新手,来自 Python,有些事情的完成方式非常不同。在 Python 中,可以通过键入 from foo import bar 从 .py 文件导入单个函数,但我仍然没有在 Rust 中找到任何等效函数。

我有以下文件:

.
├── main.rs
└── module.rs

内容如下:

main.rs

mod module;

fn main() {
    module::hello();
}

module.rs

pub fn hello() {
    println!("Hello");
}

pub fn bye() {
    println!("Bye");
}

如何创建我的模块或输入我的导入,这样我就不会收到以下警告:

warning: function is never used: `bye`
  --> module.rs:5:1
   |
 5 |     pub fn bye() {
   |     ^^^^^^^^^^^^
   |
   = note: #[warn(dead_code)] on by default

与导入模块、类型、函数和特征没有什么本质上的不同:

use path::to::function;

例如:

mod foo {
    pub fn bar() {}
}

use foo::bar;

fn main() {
    bar();
}