# Lifetime errors with Generic and FnOnce

**URL:** <https://users.rust-lang.org/t/lifetime-errors-with-generic-and-fnonce/84324>\
**Category:** help\
**Created:** [November 14, 2022, 11:57pm UTC](https://users.rust-lang.org/t/lifetime-errors-with-generic-and-fnonce/84324 "2022-11-14T23:57:53Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![quinedot](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/quinedot/32/17693_2.png) [@quinedot](https://users.rust-lang.org/u/quinedot)\
**Post date:** [November 15, 2022, 12:28am UTC](https://users.rust-lang.org/t/lifetime-errors-with-generic-and-fnonce/84324/4 "2022-11-15T00:28:54Z")

</div>

You may need to rely on a trait to emulate a generic type constructor; [here's one way,](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=dd3216ad6b0f164c5e0d7d3057ed5f06) perhaps not fully applicable to your use case due to the blanket implementation for `T: Sized`.

[Here's more on the issue generally](https://users.rust-lang.org/t/problems-matching-up-lifetimes-between-various-traits-and-closure-parameters/71994/7) -- in short, a type parameter like `T` can only resolve to a single explicit type (including all lifetimes), and not a type constructor like `&str` or `YourType<'_>` (over any possible lifetime).

Using an emulated type constructor like this does also tend to wreck inference. Dropping blanket implementations for concrete ones can help at the expense of being unrestrictedly generic. I don't know of any silver bullet though.

---

_[View the full topic](https://users.rust-lang.org/t/lifetime-errors-with-generic-and-fnonce/84324)._
