<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] ### 實現struct HelloWorld 讓我們為 "hello world" future 實現它: ``` extern crate futures; use futures::{Future, Async, Poll}; use std::fmt; struct HelloWorld; impl Future for HelloWorld { type Item = String; type Error = (); fn poll(&mut self) ->Poll<Self::Item, Self::Error> { Ok(Async::Ready("hello world".to_string())) } } ``` ### 實現struct Display 讓我們把 future 打印到標準輸出(stdout)中. 我們將通過一個`Display`future 來實現這個效果。 ``` struct Display<T>(T); impl<T> Future for Display<T> where T: Future, T::Item : fmt::Display { type Item = (); type Error = T::Error; fn poll(&mut self) -> Poll<(), T::Error> { let value = try_ready!(self.0.poll()); println!("{}", value); Ok(Async::Ready(())) } } ``` 調用 ``` fn main() { let future = Display(HelloWorld); tokio::run(future); } ``` ### 疑問 #### where是什么意思 ``` where T: Future, T::Item :fmt::Display 是什么意思? ``` #### poll函數是什么時候調用的。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看