mainで利用するモジュールを定義し、使用する方のモジュールで、 use crate::${modName} と定義する。
main.rsで両方のモジュールを定義していないとエラーになるので注意が必要
main.rs
mod account; mod crypt;
account.rs
use crate::crypt; // println!("{}", crypt::password_verify(&loginform.password, &password_hash));
crypt.rs
use pwhash::bcrypt; pub fn password_verify(password: &String, hash: &String) -> bool { bcrypt::verify(password, hash) }
なるほどなるほど!