buf is returned from rd.fill_buf(), and points to inside rd, so it is the same reference.
Then rd.consume wants to borrow rd again, but can't, because buf-from-rd is still borrowed. The compiler will borrow rd.consume first, then evaluate buf.len(), then call it.
When you move len = buf.len() a line earlier, then borrow of buf can end before call to rd.consume.