-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meta tracking issue for impl Trait
#63066
Comments
#65481 Allow |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@sighoya @Aaron1011 @mark-i-m @CryZe This issue is not for general discussion about
|
The existing issue rust-lang#34511 has been closed and replaced by meta-issue rust-lang#63066. The concrete part of the new meta-issue for this feature should be rust-lang#63065.
This links to #29661 which seems to be about setting associated type defaults, whereas I understood the text to mean something like this: trait SomeTrait {
type Foo: Bar;
fn foo() -> Self::Foo;
}
impl SomeTrait for X {
type Foo = impl Bar;
fn foo() -> Self::Foo { ... }
} I didn't perceive #29661 to be about this use-case, but instead about something different: trait SomeTrait {
type Foo: Bar = SomeSpecificBar;
} I understood " |
Trait definitions is your second example, covered by #29661. Your first example is trait implementations, which is covered by RFC 2515 (#63063), specifically the last example of RFC 2515 § Guide-level explanation § Type alias, and it currently works on nightly with |
Thanks @Nemo157. I would find amendment to the issue text here to make clear that the link to #63063 also encompasses trait implementations and that the sub-link to #29661 is only about associated type defaults helpful. At the moment, the implication of the text is that #63063 is only about "bare" type aliases and #29661 is about impl Trait in associated types. |
Hello, does this include allowing E.g. - struct Session {
client: websocket::sync::Client<impl websocket::sync::Stream>
}
The current workaround for doing this is quite unergonomic - use anyhow::Result;
use websocket;
fn main() -> Result<()> {
let session = create_session()?;
Ok(())
}
struct Session<T: websocket::sync::Stream> {
client: websocket::sync::Client<T>,
}
fn create_session() -> Result<Session<impl websocket::sync::Stream>> {
let client = websocket::ClientBuilder::new("ws://...")?.connect_insecure()?;
Ok(Session { client })
} vs if this was implemented - use anyhow::Result;
use websocket;
fn main() -> Result<()> {
let session = Session::new()?;
Ok(())
}
struct Session {
client: websocket::sync::Client<impl websocket::sync::Stream>
}
impl Session {
fn new() -> Result<Self> {
let client = websocket::ClientBuilder::new("ws://...")?.connect_insecure()?;
Ok(Session { client })
}
} |
@ibraheemdev #63063 |
Memory discovery (finding how much we have, where etc...) shouldn't be hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait so that each platform can do its thing (riscv/arm => device tree, x86 => multiboot info or e820). Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>` method in the Architecture trait. But oh boy no... Currently a method that returns an impl Trait is not possible (rustc 1.59.0-nightly). In the future, this should be possible, see: rust-lang/rust#63066 Meanwhile, this is what I came up with. Since I can't return an impl Trait but I can pass one as parameter, I have a `for_all_memory_regions` method that creates the iterator and then calls the closure with that parameter. Code that uses that is a bit more ugly and less clear than if I could have returned an impl Trait, but it should do for now. This MUST be fixed when the above issue is resolved. Also the type signatures are a bit *complex*, this is due to my vicious fight with the rust borrow-checking-and-mighty-type-checking gods of Rust. Last but not least, a quote from the great: Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre -- Garnier
Memory discovery (finding how much we have, where etc...) shouldn't be hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait so that each platform can do its thing (riscv/arm => device tree, x86 => multiboot info or e820). Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>` method in the Architecture trait. But oh boy no... Currently a method that returns an impl Trait is not possible (rustc 1.59.0-nightly). In the future, this should be possible, see: rust-lang/rust#63066 Meanwhile, this is what I came up with. Since I can't return an impl Trait but I can pass one as parameter, I have a `for_all_memory_regions` method that creates the iterator and then calls the closure with that parameter. Code that uses that is a bit more ugly and less clear than if I could have returned an impl Trait, but it should do for now. This MUST be fixed when the above issue is resolved. Also the type signatures are a bit *complex*, this is due to my vicious fight with the rust borrow-checking-and-mighty-type-checking gods of Rust. Last but not least, a quote from the great: Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre -- Garnier
Memory discovery (finding how much we have, where etc...) shouldn't be hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait so that each platform can do its thing (riscv/arm => device tree, x86 => multiboot info or e820). Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>` method in the Architecture trait. But oh boy no... Currently a method that returns an impl Trait is not possible (rustc 1.59.0-nightly). In the future, this should be possible, see: rust-lang/rust#63066 Meanwhile, this is what I came up with. Since I can't return an impl Trait but I can pass one as parameter, I have a `for_all_memory_regions` method that creates the iterator and then calls the closure with that parameter. Code that uses that is a bit more ugly and less clear than if I could have returned an impl Trait, but it should do for now. This MUST be fixed when the above issue is resolved. Also the type signatures are a bit *complex*, this is due to my vicious fight with the rust borrow-checking-and-mighty-type-checking gods of Rust. Last but not least, a quote from the great: Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre -- Garnier
Memory discovery (finding how much we have, where etc...) shouldn't be hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait so that each platform can do its thing (riscv/arm => device tree, x86 => multiboot info or e820). Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>` method in the Architecture trait. But oh boy no... Currently a method that returns an impl Trait is not possible (rustc 1.59.0-nightly). In the future, this should be possible, see: rust-lang/rust#63066 Meanwhile, this is what I came up with. Since I can't return an impl Trait but I can pass one as parameter, I have a `for_all_memory_regions` method that creates the iterator and then calls the closure with that parameter. Code that uses that is a bit more ugly and less clear than if I could have returned an impl Trait, but it should do for now. This MUST be fixed when the above issue is resolved. Also the type signatures are a bit *complex*, this is due to my vicious fight with the rust borrow-checking-and-mighty-type-checking gods of Rust. Last but not least, a quote from the great: Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre -- Garnier
Memory discovery (finding how much we have, where etc...) shouldn't be hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait so that each platform can do its thing (riscv/arm => device tree, x86 => multiboot info or e820). Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>` method in the Architecture trait. But oh boy no... Currently a method that returns an impl Trait is not possible (rustc 1.59.0-nightly). In the future, this should be possible, see: rust-lang/rust#63066 Meanwhile, this is what I came up with. Since I can't return an impl Trait but I can pass one as parameter, I have a `for_all_memory_regions` method that creates the iterator and then calls the closure with that parameter. Code that uses that is a bit more ugly and less clear than if I could have returned an impl Trait, but it should do for now. This MUST be fixed when the above issue is resolved. Also the type signatures are a bit *complex*, this is due to my vicious fight with the rust borrow-checking-and-mighty-type-checking gods of Rust. Last but not least, a quote from the great: Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre -- Garnier
Memory discovery (finding how much we have, where etc...) shouldn't be hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait so that each platform can do its thing (riscv/arm => device tree, x86 => multiboot info or e820). Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>` method in the Architecture trait. But oh boy no... Currently a method that returns an impl Trait is not possible (rustc 1.59.0-nightly). In the future, this should be possible, see: rust-lang/rust#63066 Meanwhile, this is what I came up with. Since I can't return an impl Trait but I can pass one as parameter, I have a `for_all_memory_regions` method that creates the iterator and then calls the closure with that parameter. Code that uses that is a bit more ugly and less clear than if I could have returned an impl Trait, but it should do for now. This MUST be fixed when the above issue is resolved. Also the type signatures are a bit *complex*, this is due to my vicious fight with the rust borrow-checking-and-mighty-type-checking gods of Rust. Last but not least, a quote from the great: Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre -- Garnier
Memory discovery (finding how much we have, where etc...) shouldn't be hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait so that each platform can do its thing (riscv/arm => device tree, x86 => multiboot info or e820). Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>` method in the Architecture trait. But oh boy no... Currently a method that returns an impl Trait is not possible (rustc 1.59.0-nightly). In the future, this should be possible, see: rust-lang/rust#63066 Meanwhile, this is what I came up with. Since I can't return an impl Trait but I can pass one as parameter, I have a `for_all_memory_regions` method that creates the iterator and then calls the closure with that parameter. Code that uses that is a bit more ugly and less clear than if I could have returned an impl Trait, but it should do for now. This MUST be fixed when the above issue is resolved. Also the type signatures are a bit *complex*, this is due to my vicious fight with the rust borrow-checking-and-mighty-type-checking gods of Rust. Last but not least, a quote from the great: Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre -- Garnier
Memory discovery (finding how much we have, where etc...) shouldn't be hardcoded in `mm/mod.rs`. Instead it should be in the Architecture trait so that each platform can do its thing (riscv/arm => device tree, x86 => multiboot info or e820). Originaly I just wanted a `memory_regions -> impl Iterator<Item=T>` method in the Architecture trait. But oh boy no... Currently a method that returns an impl Trait is not possible (rustc 1.59.0-nightly). In the future, this should be possible, see: rust-lang/rust#63066 Meanwhile, this is what I came up with. Since I can't return an impl Trait but I can pass one as parameter, I have a `for_all_memory_regions` method that creates the iterator and then calls the closure with that parameter. Code that uses that is a bit more ugly and less clear than if I could have returned an impl Trait, but it should do for now. This MUST be fixed when the above issue is resolved. Also the type signatures are a bit *complex*, this is due to my vicious fight with the rust borrow-checking-and-mighty-type-checking gods of Rust. Last but not least, a quote from the great: Tout est simple, tout est complexe, a vous de trouver la solution, une solution peut en cacher une autre -- Garnier
This issue tracks the progress of
impl Trait
in general.This issue is not for discussion about specific extensions to
impl Trait
and only exists to provide links to other places that track the progress of specific issues. If you wish to discuss some subject related toimpl Trait
, please find an existing appropriate issue below or create an new issue and comment here with a link to the newly created issue.The
impl Trait
related issues currently on deck are as follows:A-impl-trait
type Foo = impl Bar;
. Tracking issue for RFC 2515, "Permit impl Trait in type aliases" #63063type Foo = impl Bar;
intrait
definitions. Tracking issue for RFC 2532, "Associated type defaults" #29661const
andstatic
items andlet
bindings. Tracking issue forimpl Trait
inconst
andstatic
items andlet
bindings #63065impl Trait
requires a named lifetime #49287impl Trait
after->
infn
types or parentheses sugar? [impl Trait] Should we allowimpl Trait
after->
infn
types or parentheses sugar? #45994impl Trait
in return type position by anonymization. #35091 (comment)fn foo<T>(x: impl Iterator<Item = T>>)
?impl Trait
as arguments in the list, permitting migration]Open RFCs:
None.
The text was updated successfully, but these errors were encountered: