The error E0425 occurs because the variable you are trying to use is not defined in the current scope or is private to a parent module. You must either define the variable, bring it into scope with a use statement, or change its visibility to pub.
// Example: Fixing a private function call from a child module
fn deliver_order() {}
mod back_of_house {
// Error E0425: cannot find value `deliver_order` in this scope
// Fix: Add `pub` to the parent function or use `super::` if already public
fn fix_incorrect_order() {
cook_order();
super::deliver_order(); // Requires `deliver_order` to be `pub`
}
fn cook_order() {}
}
If the item is in a different module, ensure it is marked pub and imported:
mod kitchen {
pub fn cook() {} // Must be public
}
use kitchen::cook; // Bring into scope
fn main() {
cook(); // Now works
}
If the variable is a typo, correct the spelling to match the definition.