# error[E0597]: borrowed value does not live long enough

note: argument requires that `value` is borrowed for `'static`

- **ID:** `rust/e0597-borrowed-value-from-iterator`
- **Domain:** rust
- **Category:** type_error
- **Error Code:** `E0597`
- **Verification:** ai_generated
- **Fix Rate:** 87%

## Root Cause

Returning a reference to a local variable created inside a function or closure, often from an iterator chain like `.filter()` or `.map()`.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| rustc 1.76 | active | — | — |
| rustc 1.77 | active | — | — |

## Workarounds

1. **Clone or own the data instead of borrowing: `let cloned = value.clone();` or collect into a `Vec` before returning.** (90% success)
   ```
   Clone or own the data instead of borrowing: `let cloned = value.clone();` or collect into a `Vec` before returning.
   ```
2. **Restructure the code to pass ownership: change function signature to return an owned type like `String` instead of `&str`.** (85% success)
   ```
   Restructure the code to pass ownership: change function signature to return an owned type like `String` instead of `&str`.
   ```

## Dead Ends

- **** — The data still doesn't live long enough; the lifetime bound is a promise the compiler enforces, not a magic fix. (80% fail)
- **** — Can cause dangling pointers and undefined behavior; highly discouraged. (95% fail)
