0
以下對我來說似乎是一個錯誤。如何在where子句中使用關聯的常量?
struct Seq([u8; 8]);
impl From<[u8; 8]> for Seq {
fn from(data: [u8; 8]) -> Seq {
Seq(data)
}
}
trait Sequence {
const LEN: usize;
}
impl Sequence for Seq {
const LEN: usize = 8;
}
trait ByteSequence {
fn check();
}
impl<S> ByteSequence for S
where
S: Sequence + From<[u8; <S as Sequence>::LEN]>,
{
fn check() {}
}
結果如下錯誤:playground
error[E0277]: the trait bound `S: Sequence` is not satisfied
--> src/main.rs:23:29
|
23 | S: Sequence + From<[u8; <S as Sequence>::LEN]>,
| ^^^^^^^^^^^^^^^^^^^^ the trait `Sequence` is not implemented for `S`
|
= help: consider adding a `where S: Sequence` bound
= note: required by `Sequence::LEN`
我還試圖加入結合在一個額外的行或直接在IMPL聲明。
好的...我會那樣做的! [完成](https://github.com/rust-lang/rust/issues/44774) – JDemler