The std::io traits we mimic are object safe so it seems ours should be also.
I would expect this to build but it does not because of our take() implementation.
#[test]
fn object_safety() {
// Sanity check, these are all object safe.
struct StdlibTraits {
p: Box<dyn std::io::Read>,
q: Box<dyn std::io::Write>,
r: Box<dyn std::io::BufRead>,
}
// If this builds then our three traits are object safe also.
struct OurTraits {
p: Box<dyn Read>,
q: Box<dyn Write>,
r: Box<dyn BufRead>,
}
}
Clue: We may need a where clause.
/// Constructs a new adapter which will read at most `limit` bytes.
#[inline]
fn take(&mut self, limit: u64) -> Take<Self>
where
Self: Sized,
{
Take { reader: self, remaining: limit }
}
The
std::iotraits we mimic are object safe so it seems ours should be also.I would expect this to build but it does not because of our
take()implementation.Clue: We may need a
whereclause.