Closed
Description
error[E0275]: overflow evaluating the requirement &mut bytes::bytes_mut::BytesMut: bytes::buf::buf_impl::Buf
Here's a link to the playground : https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=e0d226183c371b79d9a234ccebdeafd0
I tried this code:
use bytes::{Buf, BytesMut};
fn get_value<B>(buf: &mut B) -> Result<i32, String>
where
B: Buf,
{
Ok(42)
}
fn do_more<B>(mut buf: B) -> Result<i32, String>
where
B: Buf,
{
if buf.has_remaining() {
get_value(&mut buf)
} else {
do_more(&mut buf)
}
}
fn main() {
let payload = vec![1, 2, 3, 4, 5];
let parsed = do_more(&mut BytesMut::from(&*payload)).unwrap();
}
I expected to see this happen: Nothing really, but I would love to see an error message that would help me out here ^^.
Instead, this happened:
Meta
rustc --version --verbose
:
playground (stable) and tested it on my machine: rustc 1.43.1 (8d69840ab 2020-05-04)
Link to the twitter discussion https://twitter.com/ekuber/status/1264962969206525952?s=20
Paging @estebank who might be interested <3