I am doing some USB work and my design has a generic buffer type with trait bounds AsRef<[u8]>
and AsMut<[u8]>
. I am finding that these trait bounds "infect" all higher layers and I have to repeatedly specify them. Is there a way to tidy this up? Example:
pub struct Transfer<B: AsRef<[u8]> + AsMut<[u8]>> {
pub buf: B,
// ...
}
impl<B: AsRef<[u8]> + AsMut<[u8]>> Transfer<B> {
// ...
}
pub struct Device<B: AsRef<[u8]> + AsMut<[u8]>> {
transfers: Vec<Option<Transfer<B>>>,
// ...
}
impl<B: AsRef<[u8]> + AsMut<[u8]>> Device<B> {
// ...
}
impl<B: AsRef<[u8]> + AsMut<[u8]>> Evented for Device<B> {
// ...
}