# Idea: Making unnameable types nameable

**URL:** <https://internals.rust-lang.org/t/idea-making-unnameable-types-nameable/7797>\
**Category:** language design\
**Created:** [June 25, 2018, 2:01am UTC](https://internals.rust-lang.org/t/idea-making-unnameable-types-nameable/7797 "2018-06-25T02:01:33Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![MajorBreakfast](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/majorbreakfast/32/4015_2.png) [@MajorBreakfast](https://internals.rust-lang.org/u/MajorBreakfast)\
**Post date:** [June 25, 2018, 1:10pm UTC](https://internals.rust-lang.org/t/idea-making-unnameable-types-nameable/7797/7 "2018-06-25T13:10:20Z")

</div>

Here's an example for abstract types (as defined the RFC @Centril mentioned):

```rust
abstract type Foo: MyTrait<Item = i32>;
fn foo() -> Foo

```

Note: The concrete syntax is in flux (see debate about this in the [tracking issue](https://github.com/rust-lang/rust/issues/34511)

Alternatively there was also an extensive debate about making it possible to name the output of a function by accessing its `Output` associated type in [Pre-Pre-RFC: async methods & bounding async fns](https://internals.rust-lang.org/t/pre-pre-rfc-async-methods-bounding-async-fns/7656) I think that this would work best in addition to abstract types, not as a replacement.

> [@jjpe](#):
>
> I’m kind of missing in the RFC is using `impl Trait` in field position. Is that coming at all?

I don't think this is coming. Generic structs require that you define type parameters for a reason (e.g. `T` in `struct Vec<T>)`. Type params are needed to name the type later, e.g. `Vec<i32>`. With `impl Trait` there would be no type parameters and the system can't work without them.

> [@vorner](#):
>
> On the other hand, I’m not sure if these problems still _need_ to be solved, with `impl Trait` and all that ‒ if we could have been able to name all the types from the beginning, we probably wouldn’t have needed `impl Trait` at all.

You're disregarding a major use case of `impl Trait`. Instead of returning something like `std::iter::Filter<std::iter::Map<std::vec::IntoIter<i32>` you can return `impl Iterator<Item = i32>`. It makes it possible to conveniently not expose implementation details as public API.

---

_[View the full topic](https://internals.rust-lang.org/t/idea-making-unnameable-types-nameable/7797)._
