Merge branch 'master' into edit

This commit is contained in:
Sunface
2022-11-07 08:27:51 +08:00
committed by GitHub
17 changed files with 34 additions and 32 deletions

View File

@ -2,7 +2,7 @@
### Char
1. 🌟
```rust, editable
```rust,editable
// Make it work
use std::mem::size_of_val;
@ -18,7 +18,7 @@ fn main() {
```
2. 🌟
```rust, editable
```rust,editable
// Make it work
fn main() {
@ -33,7 +33,7 @@ fn print_char(c : char) {
### Bool
3. 🌟
```rust, editable
```rust,editable
// Make println! work
fn main() {
@ -47,7 +47,7 @@ fn main() {
```
4. 🌟
```rust, editable
```rust,editable
// Make it work
fn main() {

View File

@ -24,7 +24,7 @@ fn main() {
2. 🌟
```rust,editable
// Fill the blank
// Fill the blank
fn main() {
let v: u16 = 38_u8 as __;

View File

@ -240,7 +240,7 @@ Besides jump into the standard library, you can also jump to another module in t
// in lib.rs
mod a {
/// Add four to the given value and return a [`Option`] type
/// Add four to the given value and return a [`Option`] type
/// [`crate::MySpecialFormatter`]
pub fn add_four(x: i32) -> Option<i32> {
Some(x + 4)

View File

@ -335,7 +335,7 @@ The `impl Trait` syntax works for straightforward cases but is actually syntax s
When working with generics, the type parameters often must use traits as bounds to stipulate what functionality a type implements.
7. 🌟🌟
```rust, editable
```rust,editable
fn main() {
assert_eq!(sum(1, 2), 3);
}

View File

@ -108,7 +108,9 @@ fn main() {
## T: 'static
As a trait bound, it means the type does not contain any non-static references. Eg. the receiver can hold on to the type for as long as they want and it will never become invalid until they drop it.
It's important to understand this means that any owned data always passes a `'static `lifetime bound, but a reference to that owned data generally does no.
It's important to understand this means that any owned data always passes a `'static `lifetime bound, but a reference to that owned data generally does not.
5,🌟🌟
```rust,editable
@ -192,4 +194,4 @@ fn print_f(t: &(impl Display + 'static)) {
fn print_g(t: &'static String) {
println!("{}", t);
}
```
```

View File

@ -62,7 +62,7 @@ fn print_str(s: String) {
```
5. 🌟🌟
```rust, editable
```rust,editable
// Don't use clone ,use copy instead
fn main() {
let x = (1, 2, (), "hello".to_string());

View File

@ -204,7 +204,7 @@ fn main() {
_ => ()
}
}
```
```
> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it

View File

@ -114,6 +114,6 @@ fn main() {
&mut value => value.push_str(" world!")
}
}
````
```
> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it