Skip to content
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

Implement DerefAsync and DerefMutAsync as Deref and DerefMut in async context #50458

Closed
ijsgaus opened this issue May 5, 2018 · 5 comments
Closed
Labels
A-async-await Area: Async & Await C-enhancement Category: An issue proposing an enhancement or a PR with one. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@ijsgaus
Copy link

ijsgaus commented May 5, 2018

Introduce traits:

pub trait DerefAsync {
    type Target: Deref<Target::T>;
    async fn derefAsync(&self) -> Async<T>;
}

impl Deref for T: DerefAsync<Target::TOut> + TOut: Deref<Target :: TOut1>
{
   type Target : Async<TOut1>
   fn deref(&self) {
      self.derefAsync().AndAlso(move |t| t.deref());
   }
}

Add support for awaiting derefs. This can be very useful, EG, in async realization of lazy pattern:

   let y = 5;
   let lazy = async_lazy!(y, async |a| await!(a + 2));  
   let x : i32 = await!(lazy);
@ishitatsuyuki
Copy link
Contributor

ishitatsuyuki commented May 5, 2018

Can you comment on the await RFC PR or once it merged, the tracking issue? Language decisions should always happen there.

@ijsgaus
Copy link
Author

ijsgaus commented May 5, 2018

@ishitatsuyuki Can you give me reference link, i don't know, where it is

@sfackler
Copy link
Member

sfackler commented May 5, 2018

rust-lang/rfcs#2394

@XAMPPRocky XAMPPRocky added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-lang Relevant to the language team, which will review and decide on the PR/issue. A-async-await Area: Async & Await labels Oct 2, 2018
@cramertj
Copy link
Member

Closing-- proposals for new features belong on the RFCs repo or in an internals post.

@nikomatsakis
Copy link
Contributor

@ijsgaus thanks for the suggestion! I'm going to close this, though, as we don't generally keep have issues in this repo suggested possible future enhancements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await C-enhancement Category: An issue proposing an enhancement or a PR with one. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants