我有類似下面的代碼:「太多的參數」上完全正常的功能
pub trait WorldImpl {
fn new(size: (usize, usize), seed: u32) -> World;
fn three() -> bool;
fn other() -> bool;
fn non_self_methods() -> bool;
}
pub type World = Vec<Vec<UnitOfSpace>>;
// I'm doing this because I want a SPECIAL version of Vec<Vec<UnitOfSpace>>, so I can treat it like a struct but have it be a normal type underneath.
impl WorldImpl for World {
fn new(size: (usize, usize), seed: u32) -> World {
// Code
vec![/* vector stuff */]
}
// Implement other three methods
}
let w = World::new((120, 120), /* seed from UNIX_EPOCH stuff */);
而且我得到這個錯誤,這顯然是錯誤的:
error[E0061]: this function takes 0 parameters but 2 parameters were supplied
--> src/main.rs:28:28
|
28 | let world = World::new((120 as usize, 120 as usize),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 0 parameters
我想兩件事情:
這不是慣用的,Rust從來沒有用過這種方式。在這種情況下,我需要知道如何真正做到這一點。
這是一個愚蠢的錯誤,我錯過了。
當我在操場上嘗試類似上面的代碼時,它工作得很好,沒有錯誤。我還沒有找到任何其他地方的任何錯誤信息,所以我不會驚訝地發現我只是使用錯誤的語言。我對我的任何代碼都沒有特別的依戀,所以請告訴我這個成語是什麼!
哦。啊。 *捂臉* –