我正在尝试通过将new
方法添加到以下位置来制作原始类型和对象类型usize
:
impl usize {
fn new(value: &u32) -> usize {
value as usize
}
}
我不知道该消息试图说什么:
error[E0390]: only a single inherent implementation marked with `#[lang = "usize"]` is allowed for the `usize` primitive
--> src/lib.rs:1:1
|
1 | / impl usize {
2 | | fn new(value: &u32) -> usize {
3 | | value as usize
4 | | }
5 | | }
| |_^
|
help: consider using a trait to implement these methods
--> src/lib.rs:1:1
|
1 | / impl usize {
2 | | fn new(value: &u32) -> usize {
3 | | value as usize
4 | | }
5 | | }
| |_^