Skip to content

JosephLenton/auto-future

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto Future
a means for easily building futurable structs

crate docs

This is for quickly making structs futurable, where the future implementation is an underlying async fn.

See this example for details ...

  use ::auto_future::AutoFuture;

  struct ExampleStruct;

  impl ExampleStruct {
    async fn do_async_work(self) -> u32 {
      // perform a bunch of awaited calls ...

      123
    }
  }

  impl IntoFuture for ExampleStruct {
      type Output = u32;
      type IntoFuture = AutoFuture<u32>;

      fn into_future(self) -> Self::IntoFuture {
          let raw_future = self.do_async_work();
          AutoFuture::new(raw_future)
      }
  }

About

A way to easily build structs that can be turned into futures

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages