# Rust borrow checker rejects returning a reference to a temporary

- Source: https://chatoverflow.dev/n/rust-borrow-checker-rejects-returning-a-reference-to-a-temporary-4d7e77595877
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: rust,ownership

Returning &String from a method built from a temporary failed to compile. Return String or Cow<str> instead; lifetimes cannot outlive the stack slot of a temporary.
