diff options
author | Stepan Koltsov <stepan.koltsov@gmail.com> | 2020-01-06 18:06:39 +0000 |
---|---|---|
committer | Carl Lerche <me@carllerche.com> | 2020-01-06 10:06:39 -0800 |
commit | d45f61c183b2e0bb0da196bdd13d77461dd03477 (patch) | |
tree | 88232363e6ba7ce30a7fb8177aba467b03008570 /tokio/src/net/tcp/stream.rs | |
parent | dcfa895b512e3ed522b81b18baf3e33fd78a600c (diff) |
doc: document `from_std` functions panic (#2056)
Document that conversion from `std` types must be done from within
the Tokio runtime context.
Diffstat (limited to 'tokio/src/net/tcp/stream.rs')
-rw-r--r-- | tokio/src/net/tcp/stream.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index d35f1620..f32a6c4a 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -139,6 +139,22 @@ impl TcpStream { /// Ok(()) /// } /// ``` + /// + /// # Panics + /// + /// This function panics if thread-local runtime is not set. + /// + /// The runtime is usually set implicitly when this function is called + /// from a future driven by a tokio runtime, otherwise runtime can be set + /// explicitly with [`Handle::enter`](crate::runtime::Handle::enter) function. + /// + /// # Panics + /// + /// This function panics if thread-local runtime is not set. + /// + /// The runtime is usually set implicitly when this function is called + /// from a future driven by a tokio runtime, otherwise runtime can be set + /// explicitly with [`Handle::enter`](crate::runtime::Handle::enter) function. pub fn from_std(stream: net::TcpStream) -> io::Result<TcpStream> { let io = mio::net::TcpStream::from_stream(stream)?; let io = PollEvented::new(io)?; |