diff --git a/src/advance/into-types/sized.md b/src/advance/into-types/sized.md index a0cab853..2c75a31a 100644 --- a/src/advance/into-types/sized.md +++ b/src/advance/into-types/sized.md @@ -120,7 +120,7 @@ fn main() { 报错如下: -``` +```console error[E0277]: the size for values of type `str` cannot be known at compilation time --> src/main.rs:2:24 | diff --git a/src/appendix/rust-versions/1.64.md b/src/appendix/rust-versions/1.64.md index 5b93c1f9..c9ffa3d4 100644 --- a/src/appendix/rust-versions/1.64.md +++ b/src/appendix/rust-versions/1.64.md @@ -40,7 +40,7 @@ let response = StorageRequest::new() // 1. 实例化 这个代码已经不错了,不过 1.64 后可以做的更好。使用 `IntoFuture` ,把第三步的 “构造 future ” 和 第四步的 “执行 future ” 合并到一个步骤里: -```RUST +```rust,ignore,mdbook-runnable let response = StorageRequest::new() // 1. 实例化 .set_debug(true) // 2. 设置一些选项 .await?; // 3. 构造并执行 future ,传递 error @@ -48,7 +48,7 @@ let response = StorageRequest::new() // 1. 实例化 想要实现上面的效果,我们需要给 `StorageRequest` 实现 `IntoFuture` trait。`IntoFuture` 需要确定好要返回的 future,可以用下面的代码来实现: -```rust +```rust,ignore,mdbook-runnable // 首先需要引入一些必须的类型 use std::pin::Pin; use std::future::{Future, IntoFuture}; diff --git a/src/basic/collections/vector.md b/src/basic/collections/vector.md index b52a11d2..c4f95fbb 100644 --- a/src/basic/collections/vector.md +++ b/src/basic/collections/vector.md @@ -334,7 +334,7 @@ fn main() { 结果,居然报错了, -``` +```console error[E0277]: the trait bound `f32: Ord` is not satisfied --> 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 }] ``` @@ -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 }] ``` diff --git a/src/basic/crate-module/module.md b/src/basic/crate-module/module.md index 89559636..76de7803 100644 --- a/src/basic/crate-module/module.md +++ b/src/basic/crate-module/module.md @@ -336,7 +336,7 @@ pub fn add_to_waitlist() {} 现在,我们尝试编译程序,很遗憾,编译器报错: -``` +```console error[E0583]: file not found for module `front_of_house` --> src/lib.rs:3:1 | diff --git a/src/basic/trait/trait-object.md b/src/basic/trait/trait-object.md index d7228661..75dd1459 100644 --- a/src/basic/trait/trait-object.md +++ b/src/basic/trait/trait-object.md @@ -274,7 +274,7 @@ fn draw2(x: dyn Draw) { } ``` -``` +```console 10 | fn draw2(x: dyn Draw) { | ^ 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 --> src/lib.rs:2:5 | diff --git a/src/compiler/fight-with-compiler/lifetime/closure-with-static.md b/src/compiler/fight-with-compiler/lifetime/closure-with-static.md index 9316d384..2de837da 100644 --- a/src/compiler/fight-with-compiler/lifetime/closure-with-static.md +++ b/src/compiler/fight-with-compiler/lifetime/closure-with-static.md @@ -53,7 +53,7 @@ fn main() { } ``` -``` +```console error[E0310]: the parameter type `impl Fn(&str) -> Res` may not live long enough --> src/main.rs:25:30 | diff --git a/src/profiling/performance/deep-into-move.md b/src/profiling/performance/deep-into-move.md index 1a07bde7..4f1d8b28 100644 --- a/src/profiling/performance/deep-into-move.md +++ b/src/profiling/performance/deep-into-move.md @@ -214,7 +214,7 @@ fn main() { 输出如下: -``` +```console 0x138008010 0x138008010 0x138008010