Cannot move out of borrowed content / cannot move out of behind a shared reference

Let’s look at the signature for into_bytes: fn into_bytes(self) -> Vec<u8> This takes self, not a reference to self (&self). That means that self will be consumed and won’t be available after the call. In its place, you get a Vec<u8>. The prefix into_ is a common way of denoting methods like this. I don’t … Read more

Why are explicit lifetimes needed in Rust?

The other answers all have salient points (fjh’s concrete example where an explicit lifetime is needed), but are missing one key thing: why are explicit lifetimes needed when the compiler will tell you you’ve got them wrong? This is actually the same question as “why are explicit types needed when the compiler can infer them”. … Read more

tech