Are values from types with lifetime parameters references?!

Hey folks,

I've ran a snippet from here in the playground and the error says:

(...) ioo is a reference that is only valid in the function body (...)

This confuses me because it looks to me as if an owned value gets moved into the function and not a reference.

Could somebody explain why the compiler is talking here about a reference?

Regards
keks

The error should say "value" or something, not reference.

In practically all non-'static lifetimes arise because of a non-'static reference existing somewhere, which leads to loose language conflating lifetimes with references.[1] But it is also possible to pull them out of trait implementations or via covariance on non-references such as a trait object, etc.


  1. One common example: "T: 'static means T does not contain a non-'static reference." True, but incomplete; T can't involve any non-'static lifetime. ↩ī¸Ž

2 Likes