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

Comments

@ijsgaus
Copy link

@ijsgaus 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 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 ijsgaus commented May 5, 2018

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

@sfackler
Copy link
Member

@sfackler sfackler commented May 5, 2018

@cramertj
Copy link
Member

@cramertj cramertj commented Feb 22, 2019

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

@cramertj cramertj closed this Feb 22, 2019
@nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Feb 22, 2019

@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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants