Skip to content

Commit caf3aa5

Browse files
committed
refined examples
1 parent 3eda61d commit caf3aa5

File tree

16 files changed

+392
-31
lines changed

16 files changed

+392
-31
lines changed

ch11/a-rust-futures/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
isahc = "1.7"
109
mio = { version = "0.8", features = ["net", "os-poll"] }
10+

ch11/a-rust-futures/src/main.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ mod http;
22
mod runtime;
33
use crate::http::Http;
44

5+
56
fn main() {
67
let mut executor = runtime::init();
7-
executor.block_on(async_main());
8+
executor.block_on(async_main2());
89
}
910

1011
async fn async_main() {
@@ -15,31 +16,3 @@ async fn async_main() {
1516
println!("{txt}");
1617
}
1718

18-
// use isahc::prelude::*;
19-
20-
// async fn async_main2() {
21-
// let mut buffer = String::from("\nBUFFER:\n----\n");
22-
// let writer = &mut buffer;
23-
// println!("Program starting");
24-
// let mut res = isahc::get_async("http://127.0.0.1:8080/600/HelloAsyncAwait").await.unwrap();
25-
// let txt = res.text().await.unwrap();
26-
// writeln!(writer, "{txt}").unwrap();
27-
// let mut res = isahc::get_async("http://127.0.0.1:8080/400/HelloAsyncAwait").await.unwrap();
28-
// let txt = res.text().await.unwrap();
29-
// writeln!(writer, "{txt}").unwrap();
30-
31-
// println!("{}", buffer);
32-
// }
33-
34-
// async fn spawn_many() {
35-
// for i in 0..100 {
36-
// let delay = i * 10;
37-
// let req = format!("http://127.0.0.1:8080/{delay}/HelloAsyncAwait{i}");
38-
39-
// runtime::spawn(async move {
40-
// let mut res = isahc::get_async(&req).await.unwrap();
41-
// let txt = res.text().await.unwrap();
42-
// println!("{txt}");
43-
// });
44-
// }
45-
// }

ch11/a-rust-futures/src/runtime/executor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ where
3333
});
3434
}
3535

36-
pub struct Executor;
36+
pub struct Executor {}
3737

3838
impl Executor {
3939
pub fn new() -> Self {

0 commit comments

Comments
 (0)