|
|
Log in / Subscribe / Register

Existential types in Rust

Existential types in Rust

Posted Apr 24, 2024 16:18 UTC (Wed) by mb (subscriber, #50428)
Parent article: Existential types in Rust

> type Quux = impl Debug;
> // Later uses of 'Quux' let the compiler infer a concrete type.
> fn function3 -> Quux {

What are "later uses" exactly?
Later uses in the same file, module, crate? Or is the whole project considered?
Consider the case where `type Quux` is `pub type Quux`. Would that be possible? And what code would be included for type inference when the type is pub?


to post comments

Existential types in Rust

Posted Apr 24, 2024 16:49 UTC (Wed) by tialaramex (subscriber, #21167) [Link]

In Rust I'd expect same file. There's no way this is escaping a crate, and I'd also expect that a whole module is too much.

What we learned about inference (from languages which have a lot more inference than Rust) is that too much hurts your head just as much as none did. This is, as I understand it, why Rust forbids inference for function signatures, which is part of how we got Existential Types so early - without them I can't return a closure because closures don't have names you can spell, so I wouldn't be able to write the signature for my function that returns a closure.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds