36
我相信你做這樣的事情:如何實現一個自定義的'fmt :: Debug'特性?
extern crate uuid;
use uuid::Uuid;
use std::fmt::Formatter;
use std::fmt::Debug;
#[derive(Debug)]
struct BlahLF {
id: Uuid,
}
impl BlahLF {
fn new() -> BlahLF {
return BlahLF { id: Uuid::new_v4() };
}
}
impl Debug for BlahLF {
fn fmt(&self, &mut f: Formatter) -> Result {
write!(f.buf, "Hi: {}", self.id);
}
}
...但試圖實現這種特質產生:
error[E0243]: wrong number of type arguments
--> src/main.rs:19:41
|
19 | fn fmt(&self, &mut f: Formatter) -> Result {
| ^^^^^^ expected 2 type arguments, found 0
然而,這似乎是實現其他怎麼做到這一點。我究竟做錯了什麼?