【发布时间】:2014-03-07 06:52:44
【问题描述】:
我想你会这样做:
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
但是,这似乎是其他实现的方式。我做错了什么?
【问题讨论】:
-
粘贴示例 main/rust playground 链接也会很有用。
标签: rust