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

Open
ijsgaus opened this Issue May 5, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

ijsgaus commented May 5, 2018

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

@sfackler

This comment has been minimized.

Copy link
Member

sfackler commented May 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment