Skip to content

Commit f841a2b

Browse files
committed
format code in docs
1 parent cefc744 commit f841a2b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/lib.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,14 @@
5050
//!
5151
//! ```no_run
5252
//! # async_std::task::block_on(async {
53-
//! use hypercore_protocol::{ProtocolBuilder, Event, Message};
54-
//! use hypercore_protocol::schema::*;
5553
//! use async_std::prelude::*;
54+
//! use hypercore_protocol::{schema::*, Event, Message, ProtocolBuilder};
5655
//! // Start a tcp server.
5756
//! let listener = async_std::net::TcpListener::bind("localhost:8000").await.unwrap();
5857
//! async_std::task::spawn(async move {
5958
//! let mut incoming = listener.incoming();
6059
//! while let Some(Ok(stream)) = incoming.next().await {
61-
//! async_std::task::spawn(async move {
62-
//! onconnection(stream, false).await
63-
//! });
60+
//! async_std::task::spawn(async move { onconnection(stream, false).await });
6461
//! }
6562
//! });
6663
//!
@@ -69,7 +66,7 @@
6966
//! onconnection(stream, true).await;
7067
//!
7168
//! /// Start Hypercore protocol on a TcpStream.
72-
//! async fn onconnection (stream: async_std::net::TcpStream, is_initiator: bool) {
69+
//! async fn onconnection(stream: async_std::net::TcpStream, is_initiator: bool) {
7370
//! // A peer either is the initiator or a connection or is being connected to.
7471
//! let name = if is_initiator { "dialer" } else { "listener" };
7572
//! // A key for the channel we want to open. Usually, this is a pre-shared key that both peers
@@ -86,7 +83,7 @@
8683
//! // The handshake event is emitted after the protocol is fully established.
8784
//! Event::Handshake(_remote_key) => {
8885
//! protocol.open(key.clone()).await;
89-
//! },
86+
//! }
9087
//! // A Channel event is emitted for each established channel.
9188
//! Event::Channel(mut channel) => {
9289
//! // A Channel can be sent to other tasks.
@@ -97,7 +94,7 @@
9794
//! eprintln!("{} received message: {:?}", name, message);
9895
//! }
9996
//! });
100-
//! },
97+
//! }
10198
//! _ => {}
10299
//! }
103100
//! }

0 commit comments

Comments
 (0)