#E0032: 互相衝突的匯入
同一個名稱以不同的目標匯入了兩次,或者既被匯入,又在模組或區塊中定義。用 use .. as other; 替其中一個改名,或刪掉其中一個。
nabi
use shapes::square;
fn square(x: f64) -> f64 { x * x }
mod shapes {
pub fn square(x: f64) -> f64 { x * x }
}
error[E0032]: `square` is both imported from `shapes::square` and defined in this module --> main.nabi:1:5 | 1 | use shapes::square; | ^^^^^^ imported here 2 | fn square(x: f64) -> f64 { x * x } | -- defined here, which would hide the import | = help: import it under another name, `use shapes::square as shapes_square;`, or remove this `use` if the module does not need it
用另一個名稱匯入:
nabi
use shapes::square as shape_square;
fn square(x: f64) -> f64 { x * x }
mod shapes {
pub fn square(x: f64) -> f64 { x * x }
}
println(f"{square(2.0)} {shape_square(3.0)}");
4 9
相關錯誤碼:E0026 名稱重複定義、E0031 有歧義的名稱
發現錯誤? 在 GitHub 上編輯此頁 最後更新: