Compare commits

...

3 Commits

Author SHA1 Message Date
perro tuerto 1e076842b6 Ejercicios 3.1-4 2023-03-20 11:01:58 -07:00
perro tuerto e1bab0e4eb Repo added for zh-CN 2023-03-20 10:26:04 -07:00
perro tuerto 4978def4f5 Repo added 2023-03-20 10:22:34 -07:00
3 changed files with 11 additions and 7 deletions

View File

@ -6,7 +6,7 @@
// Fix the error below with least amount of modification to the code
fn main() {
let x: i32; // Uninitialized but used, ERROR !
let x: i32 = 5; // Uninitialized but used, ERROR !
let y: i32; // Uninitialized but also unused, only a Warning !
assert_eq!(x, 5);
@ -19,8 +19,8 @@ fn main() {
// Fill the blanks in the code to make it compile
fn main() {
let __ __ = 1;
__ += 2;
let mut x = 1;
x += 2;
assert_eq!(x, 3);
println!("Success!");
@ -40,6 +40,7 @@ fn main() {
let y: i32 = 5;
println!("The value of x is {} and value of y is {}", x, y);
}
let y: i32 = 5;
println!("The value of x is {} and value of y is {}", x, y);
}
```
@ -49,11 +50,12 @@ fn main() {
// Fix the error with the use of define_x
fn main() {
println!("{}, world", x);
let x = define_x();
println!("{}, world", x);
}
fn define_x() {
let x = "hello";
fn define_x() -> String {
String::from("hello")
}
```

View File

@ -23,8 +23,9 @@ This book was designed for easily diving into and get skilled with Rust, and it'
We use [mdbook](https://rust-lang.github.io/mdBook/) building our exercises. You can run locally with below steps:
```shell
$ git clone git@github.com:sunface/rust-by-practice.git
$ cargo install mdbook
$ cd rust-by-practice && mdbook serve
$ cd rust-by-practice && mdbook serve en/
```
## Features

View File

@ -23,6 +23,7 @@
我们使用 [mdbook](https://rust-lang.github.io/mdBook/) 构建在线练习题,你也可以下载到本地运行:
```shell
$ git clone git@github.com:sunface/rust-by-practice.git
$ cargo install mdbook
$ cd rust-by-practice && mdbook serve zh-CN/
```