Without getting into too much detail, I'm trying to use TryVec as a drop in replacement for Vec for some existing code with the intent of protecting against panics during an OOM scenario and unable to do so because TryVec does not implement std::io::Write.
Minimal example:
use fallible_collections::TryVec;
fn foo(bar: &mut impl std::io::Write) -> Result<(), std::io::Error> {
bar.write_all("baz".as_bytes())
}
fn compiles() -> Result<Vec<u8>, std::io::Error> {
let mut vec = Vec::new();
foo(&mut vec)?;
Ok(vec)
}
fn doesnt_compile() -> Result<TryVec<u8>, std::io::Error> {
let mut vec = TryVec::new();
foo(&mut vec)?; // the trait `std::io::Write` is not implemented for `TryVec<_>`
Ok(vec)
}
Is this an oversight or is there some strong reason for not having TryVec implement std::io::Write?
Without getting into too much detail, I'm trying to use
TryVec
as a drop in replacement forVec
for some existing code with the intent of protecting against panics during an OOM scenario and unable to do so becauseTryVec
does not implementstd::io::Write
.Minimal example:
Is this an oversight or is there some strong reason for not having
TryVec
implementstd::io::Write
?