我正在嘗試Rust,並且發現很難解釋當我的功能簽名與特性所期望的功能簽名不相符時該怎麼做。例如特徵錯誤消息中的預期方法簽名
impl std::fmt::Display for MyType {
// Not sure what to put here so I stub it and hope to get help from error
fn fmt() ->() { }
}
編譯器錯誤消息是
method `fmt` has a `&self` declaration in the trait, but not in the impl
我希望看到是什麼幫助我實現例如方法:
Incorrect method signature for `fmt`
Actual signature fn fmt() ->()
Expected signature fn fmt(&self, &mut Formatter) -> Result<(), Error>
是否有可能得到簽名的幫助從這樣的編譯器?我通常非常友好和詳細的編譯器錯誤給我留下了深刻的印象,所以這真的讓我感到驚訝。我正在使用防鏽操場(https://play.rust-lang.org/),但我認爲這對編譯器輸出沒有任何影響。
注意:這是[E0186](https://doc.rust-lang.org/error-index.html#E0186),並且通過問題的快速搜索沒有找到它,所以可能還沒有一個改善這個錯誤的問題。一般來說,鑑於編譯器(缺少)成熟度,Rust診斷在質量方面相當驚人,但它們確實需要更多的愛意。 –