# Inferring lifetimes in simple cases

**URL:** <https://internals.rust-lang.org/t/inferring-lifetimes-in-simple-cases/1113>\
**Category:** internals\
**Created:** [December 29, 2014, 12:27am UTC](https://internals.rust-lang.org/t/inferring-lifetimes-in-simple-cases/1113 "2014-12-29T00:27:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhart](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/mhart/32/513_2.png) [@mhart](https://internals.rust-lang.org/u/mhart)\
**Post date:** [December 29, 2014, 12:27am UTC](https://internals.rust-lang.org/t/inferring-lifetimes-in-simple-cases/1113/1 "2014-12-29T00:27:45Z")

</div>

I'm trying to understand what issues there are with the compiler inferring lifetimes in simple "single type" cases like this (instead of spitting out "missing lifetime specifier"):

```rust
fn my_fn<T>(items: T) where T: Iterator<&str> {
    println!("hello")
}

```

I'm just not sure why the lifetime needs to be explicitly stated and it can't be inferred? If the user wants an unusual lifetime like `'static` then they can declare it explicitly (analogous to how one does for mutable variables)

I raised this issue here a while back, but the discussion didn't get very far:

[https://github.com/rust-lang/rust/issues/18620](https://github.com/rust-lang/rust/issues/18620)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:23am UTC](https://internals.rust-lang.org/t/inferring-lifetimes-in-simple-cases/1113/2 "2019-03-25T08:23:27Z")

</div>

Closed on March 25, 2019, 8:23am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
