chore: add `console` in blockcode

pull/1426/head
softweitao_37264 1 year ago
parent 78c9063e95
commit 78478d60df

@ -120,7 +120,7 @@ fn main() {
报错如下: 报错如下:
``` ```console
error[E0277]: the size for values of type `str` cannot be known at compilation time error[E0277]: the size for values of type `str` cannot be known at compilation time
--> src/main.rs:2:24 --> src/main.rs:2:24
| |

@ -40,7 +40,7 @@ let response = StorageRequest::new() // 1. 实例化
这个代码已经不错了,不过 1.64 后可以做的更好。使用 `IntoFuture` ,把第三步的 “构造 future ” 和 第四步的 “执行 future ” 合并到一个步骤里: 这个代码已经不错了,不过 1.64 后可以做的更好。使用 `IntoFuture` ,把第三步的 “构造 future ” 和 第四步的 “执行 future ” 合并到一个步骤里:
```RUST ```rust,ignore,mdbook-runnable
let response = StorageRequest::new() // 1. 实例化 let response = StorageRequest::new() // 1. 实例化
.set_debug(true) // 2. 设置一些选项 .set_debug(true) // 2. 设置一些选项
.await?; // 3. 构造并执行 future ,传递 error .await?; // 3. 构造并执行 future ,传递 error
@ -48,7 +48,7 @@ let response = StorageRequest::new() // 1. 实例化
想要实现上面的效果,我们需要给 `StorageRequest` 实现 `IntoFuture` trait。`IntoFuture` 需要确定好要返回的 future可以用下面的代码来实现 想要实现上面的效果,我们需要给 `StorageRequest` 实现 `IntoFuture` trait。`IntoFuture` 需要确定好要返回的 future可以用下面的代码来实现
```rust ```rust,ignore,mdbook-runnable
// 首先需要引入一些必须的类型 // 首先需要引入一些必须的类型
use std::pin::Pin; use std::pin::Pin;
use std::future::{Future, IntoFuture}; use std::future::{Future, IntoFuture};

@ -334,7 +334,7 @@ fn main() {
结果,居然报错了, 结果,居然报错了,
``` ```console
error[E0277]: the trait bound `f32: Ord` is not satisfied error[E0277]: the trait bound `f32: Ord` is not satisfied
--> src/main.rs:29:13 --> src/main.rs:29:13
| |
@ -406,7 +406,7 @@ fn main() {
执行后输出: 执行后输出:
``` ```console
[Person { name: "Al", age: 60 }, Person { name: "Zoe", age: 25 }, Person { name: "John", age: 1 }] [Person { name: "Al", age: 60 }, Person { name: "Zoe", age: 25 }, Person { name: "John", age: 1 }]
``` ```
@ -446,7 +446,7 @@ fn main() {
执行输出 执行输出
``` ```console
[Person { name: "Al", age: 30 }, Person { name: "Al", age: 60 }, Person { name: "John", age: 1 }, Person { name: "John", age: 25 }, Person { name: "Zoe", age: 25 }] [Person { name: "Al", age: 30 }, Person { name: "Al", age: 60 }, Person { name: "John", age: 1 }, Person { name: "John", age: 25 }, Person { name: "Zoe", age: 25 }]
``` ```

@ -336,7 +336,7 @@ pub fn add_to_waitlist() {}
现在,我们尝试编译程序,很遗憾,编译器报错: 现在,我们尝试编译程序,很遗憾,编译器报错:
``` ```console
error[E0583]: file not found for module `front_of_house` error[E0583]: file not found for module `front_of_house`
--> src/lib.rs:3:1 --> src/lib.rs:3:1
| |

@ -274,7 +274,7 @@ fn draw2(x: dyn Draw) {
} }
``` ```
``` ```console
10 | fn draw2(x: dyn Draw) { 10 | fn draw2(x: dyn Draw) {
| ^ doesn't have a size known at compile-time | ^ doesn't have a size known at compile-time
| |
@ -364,7 +364,7 @@ pub struct Screen {
将会得到如下错误: 将会得到如下错误:
```text ```console
error[E0038]: the trait `std::clone::Clone` cannot be made into an object error[E0038]: the trait `std::clone::Clone` cannot be made into an object
--> src/lib.rs:2:5 --> src/lib.rs:2:5
| |

@ -53,7 +53,7 @@ fn main() {
} }
``` ```
``` ```console
error[E0310]: the parameter type `impl Fn(&str) -> Res` may not live long enough error[E0310]: the parameter type `impl Fn(&str) -> Res` may not live long enough
--> src/main.rs:25:30 --> src/main.rs:25:30
| |

@ -214,7 +214,7 @@ fn main() {
输出如下: 输出如下:
``` ```console
0x138008010 0x138008010
0x138008010 0x138008010
0x138008010 0x138008010

Loading…
Cancel
Save