@@ -62,13 +62,11 @@ impl BlockingClient {
6262 /// ```no_run
6363 /// use mini_redis::clients::BlockingClient;
6464 ///
65- /// fn main() {
66- /// let client = match BlockingClient::connect("localhost:6379") {
67- /// Ok(client) => client,
68- /// Err(_) => panic!("failed to establish connection"),
69- /// };
65+ /// let client = match BlockingClient::connect("localhost:6379") {
66+ /// Ok(client) => client,
67+ /// Err(_) => panic!("failed to establish connection"),
68+ /// };
7069 /// # drop(client);
71- /// }
7270 /// ```
7371 pub fn connect < T : ToSocketAddrs > ( addr : T ) -> crate :: Result < BlockingClient > {
7472 let rt = tokio:: runtime:: Builder :: new_current_thread ( )
@@ -91,12 +89,10 @@ impl BlockingClient {
9189 /// ```no_run
9290 /// use mini_redis::clients::BlockingClient;
9391 ///
94- /// fn main() {
95- /// let mut client = BlockingClient::connect("localhost:6379").unwrap();
92+ /// let mut client = BlockingClient::connect("localhost:6379").unwrap();
9693 ///
97- /// let val = client.get("foo").unwrap();
98- /// println!("Got = {:?}", val);
99- /// }
94+ /// let val = client.get("foo").unwrap();
95+ /// println!("Got = {val:?}");
10096 /// ```
10197 pub fn get ( & mut self , key : & str ) -> crate :: Result < Option < Bytes > > {
10298 self . rt . block_on ( self . inner . get ( key) )
@@ -117,15 +113,13 @@ impl BlockingClient {
117113 /// ```no_run
118114 /// use mini_redis::clients::BlockingClient;
119115 ///
120- /// fn main() {
121- /// let mut client = BlockingClient::connect("localhost:6379").unwrap();
116+ /// let mut client = BlockingClient::connect("localhost:6379").unwrap();
122117 ///
123- /// client.set("foo", "bar".into()).unwrap();
118+ /// client.set("foo", "bar".into()).unwrap();
124119 ///
125- /// // Getting the value immediately works
126- /// let val = client.get("foo").unwrap().unwrap();
127- /// assert_eq!(val, "bar");
128- /// }
120+ /// // Getting the value immediately works
121+ /// let val = client.get("foo").unwrap().unwrap();
122+ /// assert_eq!(val, "bar");
129123 /// ```
130124 pub fn set ( & mut self , key : & str , value : Bytes ) -> crate :: Result < ( ) > {
131125 self . rt . block_on ( self . inner . set ( key, value) )
@@ -153,22 +147,20 @@ impl BlockingClient {
153147 /// use std::thread;
154148 /// use std::time::Duration;
155149 ///
156- /// fn main() {
157- /// let ttl = Duration::from_millis(500);
158- /// let mut client = BlockingClient::connect("localhost:6379").unwrap();
150+ /// let ttl = Duration::from_millis(500);
151+ /// let mut client = BlockingClient::connect("localhost:6379").unwrap();
159152 ///
160- /// client.set_expires("foo", "bar".into(), ttl).unwrap();
153+ /// client.set_expires("foo", "bar".into(), ttl).unwrap();
161154 ///
162- /// // Getting the value immediately works
163- /// let val = client.get("foo").unwrap().unwrap();
164- /// assert_eq!(val, "bar");
155+ /// // Getting the value immediately works
156+ /// let val = client.get("foo").unwrap().unwrap();
157+ /// assert_eq!(val, "bar");
165158 ///
166- /// // Wait for the TTL to expire
167- /// thread::sleep(ttl);
159+ /// // Wait for the TTL to expire
160+ /// thread::sleep(ttl);
168161 ///
169- /// let val = client.get("foo").unwrap();
170- /// assert!(val.is_some());
171- /// }
162+ /// let val = client.get("foo").unwrap();
163+ /// assert!(val.is_none());
172164 /// ```
173165 pub fn set_expires (
174166 & mut self ,
@@ -193,12 +185,10 @@ impl BlockingClient {
193185 /// ```no_run
194186 /// use mini_redis::clients::BlockingClient;
195187 ///
196- /// fn main() {
197- /// let mut client = BlockingClient::connect("localhost:6379").unwrap();
188+ /// let mut client = BlockingClient::connect("localhost:6379").unwrap();
198189 ///
199- /// let val = client.publish("foo", "bar".into()).unwrap();
200- /// println!("Got = {:?}", val);
201- /// }
190+ /// let val = client.publish("foo", "bar".into()).unwrap();
191+ /// println!("Got = {val:?}");
202192 /// ```
203193 pub fn publish ( & mut self , channel : & str , message : Bytes ) -> crate :: Result < u64 > {
204194 self . rt . block_on ( self . inner . publish ( channel, message) )
0 commit comments