diff --git a/book/contents/advance/lifetime/static.md b/book/contents/advance/lifetime/static.md index 7b20f80b..2b45c47e 100644 --- a/book/contents/advance/lifetime/static.md +++ b/book/contents/advance/lifetime/static.md @@ -38,7 +38,7 @@ fn print(message: &T) { 但是,**`&'static` 生命周期针对的仅仅是引用,而不是持有该引用的变量,对于变量来说,还是要遵循相应的作用域规则** : ```rust -se std::{slice::from_raw_parts, str::from_utf8_unchecked}; +use std::{slice::from_raw_parts, str::from_utf8_unchecked}; fn get_memory_location() -> (usize, usize) { // “Hello World” 是字符串字面量,因此它的生命周期是 `'static`. diff --git a/book/excercises/Readme.md b/book/excercises/Readme.md deleted file mode 100644 index 27442c86..00000000 --- a/book/excercises/Readme.md +++ /dev/null @@ -1 +0,0 @@ -# Rust语言圣经课后练习题 \ No newline at end of file diff --git a/book/excercises/closure.md b/book/excercises/closure.md deleted file mode 100644 index d2c81dc5..00000000 --- a/book/excercises/closure.md +++ /dev/null @@ -1,2 +0,0 @@ -# 闭包 - diff --git a/book/excercises/lifetime.md b/book/excercises/lifetime.md deleted file mode 100644 index 40439f4e..00000000 --- a/book/excercises/lifetime.md +++ /dev/null @@ -1,26 +0,0 @@ -## 生命周期消除 - -```rust -fn print(s: &str); // elided -fn print<'a>(s: &'a str); // expanded - -fn debug(lvl: usize, s: &str); // elided -fn debug<'a>(lvl: usize, s: &'a str); // expanded - -fn substr(s: &str, until: usize) -> &str; // elided -fn substr<'a>(s: &'a str, until: usize) -> &'a str; // expanded - -fn get_str() -> &str; // ILLEGAL - -fn frob(s: &str, t: &str) -> &str; // ILLEGAL - -fn get_mut(&mut self) -> &mut T; // elided -fn get_mut<'a>(&'a mut self) -> &'a mut T; // expanded - -fn args(&mut self, args: &[T]) -> &mut Command // elided -fn args<'a, 'b, T: ToCStr>(&'a mut self, args: &'b [T]) -> &'a mut Command // expanded - -fn new(buf: &mut [u8]) -> BufWriter; // elided -fn new(buf: &mut [u8]) -> BufWriter<'_>; // elided (with `rust_2018_idioms`) -fn new<'a>(buf: &'a mut [u8]) -> BufWriter<'a> // expanded -``` \ No newline at end of file