Skip to content

Commit 3df2e6a

Browse files
committed
mdBook generated from gitorial
1 parent d121396 commit 3df2e6a

File tree

119 files changed

+282
-368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+282
-368
lines changed

src/13/solution/solution.diff

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/src/main.rs b/src/main.rs
2-
index 6c117f65..808d6732 100644
2+
index 6c117f65..8554121f 100644
33
--- a/src/main.rs
44
+++ b/src/main.rs
5-
@@ -16,22 +16,25 @@ impl Runtime {
5+
@@ -16,22 +16,22 @@ impl Runtime {
66
}
77

88
fn main() {
@@ -29,14 +29,11 @@ index 6c117f65..808d6732 100644
2929
- - We should capture the result of the transfer in an unused variable like `_res`.
3030
- */
3131
+ runtime.system.inc_nonce(&alice);
32-
+ let _res = runtime
33-
+ .balances
34-
+ .transfer(alice.clone(), bob, 30)
35-
+ .map_err(|e| eprintln!("{}", e));
32+
+ let _res = runtime.balances.transfer(alice.clone(), bob, 30).map_err(|e| eprintln!("{e}"));
3633

3734
// second transaction
3835
- /* TODO: Increment the nonce of `alice` again. */
3936
- /* TODO: Execute another balance transfer, this time from `alice` to `charlie` for 20. */
4037
+ runtime.system.inc_nonce(&alice);
41-
+ let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{}", e));
38+
+ let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{e}"));
4239
}

src/13/solution/src/main.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ fn main() {
2929

3030
// first transaction
3131
runtime.system.inc_nonce(&alice);
32-
let _res = runtime
33-
.balances
34-
.transfer(alice.clone(), bob, 30)
35-
.map_err(|e| eprintln!("{}", e));
32+
let _res = runtime.balances.transfer(alice.clone(), bob, 30).map_err(|e| eprintln!("{e}"));
3633

3734
// second transaction
3835
runtime.system.inc_nonce(&alice);
39-
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{}", e));
36+
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{e}"));
4037
}

src/13/template/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Absolutely not! This is the kind of error that our runtime should be able to han
4747
When a transaction returns an error we should show that error to the user, and then "swallow" the result. For example:
4848

4949
```rust
50-
let _res = i_can_return_error().map_err(|e| eprintln!("{}", e));
50+
let _res = i_can_return_error().map_err(|e| eprintln!("{e}"));
5151
```
5252

5353
In this case, you can see that any error that `i_can_return_error` would return gets printed to the console, but otherwise, the `Result` of that function gets placed in an unused variable `_res`.

src/14/solution/solution.diff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ index 1b9d9d85..e09906cb 100644
1212
// A simple storage mapping from accounts (`String`) to their balances (`u128`).
1313
balances: BTreeMap<String, u128>,
1414
diff --git a/src/main.rs b/src/main.rs
15-
index b79655ae..1ebef924 100644
15+
index a2e06f25..a3827f6f 100644
1616
--- a/src/main.rs
1717
+++ b/src/main.rs
1818
@@ -3,7 +3,7 @@ mod system;
@@ -24,12 +24,12 @@ index b79655ae..1ebef924 100644
2424
pub struct Runtime {
2525
system: system::Pallet,
2626
balances: balances::Pallet,
27-
@@ -39,5 +39,5 @@ fn main() {
27+
@@ -36,5 +36,5 @@ fn main() {
2828
runtime.system.inc_nonce(&alice);
29-
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{}", e));
29+
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{e}"));
3030

3131
- /* TODO: Print the final runtime state after all transactions. */
32-
+ println!("{:#?}", runtime);
32+
+ println!("{runtime:#?}");
3333
}
3434
diff --git a/src/system.rs b/src/system.rs
3535
index cbf3b195..2fc5d764 100644

src/14/solution/src/main.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@ fn main() {
3030

3131
// first transaction
3232
runtime.system.inc_nonce(&alice);
33-
let _res = runtime
34-
.balances
35-
.transfer(alice.clone(), bob, 30)
36-
.map_err(|e| eprintln!("{}", e));
33+
let _res = runtime.balances.transfer(alice.clone(), bob, 30).map_err(|e| eprintln!("{e}"));
3734

3835
// second transaction
3936
runtime.system.inc_nonce(&alice);
40-
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{}", e));
37+
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{e}"));
4138

42-
println!("{:#?}", runtime);
39+
println!("{runtime:#?}");
4340
}

src/14/template/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ With the `Debug` trait derived, you can now print the `struct` to console:
3838

3939
```rust
4040
let my_instance = MyStruct { field1: 42, field2: "Hello".to_string() };
41-
println!("{:#?}", my_instance);
41+
println!("{my_instance:#?}");
4242
```
4343

4444
The characters `:#?` help [format](https://doc.rust-lang.org/std/fmt/) the output to make it more readable.

src/14/template/src/main.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@ fn main() {
3030

3131
// first transaction
3232
runtime.system.inc_nonce(&alice);
33-
let _res = runtime
34-
.balances
35-
.transfer(alice.clone(), bob, 30)
36-
.map_err(|e| eprintln!("{}", e));
33+
let _res = runtime.balances.transfer(alice.clone(), bob, 30).map_err(|e| eprintln!("{e}"));
3734

3835
// second transaction
3936
runtime.system.inc_nonce(&alice);
40-
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{}", e));
37+
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{e}"));
4138

4239
/* TODO: Print the final runtime state after all transactions. */
4340
}

src/14/template/template.diff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ index 78f233df..1b9d9d85 100644
1111
// A simple storage mapping from accounts (`String`) to their balances (`u128`).
1212
balances: BTreeMap<String, u128>,
1313
diff --git a/src/main.rs b/src/main.rs
14-
index 808d6732..b79655ae 100644
14+
index 8554121f..a2e06f25 100644
1515
--- a/src/main.rs
1616
+++ b/src/main.rs
1717
@@ -3,6 +3,7 @@ mod system;
@@ -22,10 +22,10 @@ index 808d6732..b79655ae 100644
2222
pub struct Runtime {
2323
system: system::Pallet,
2424
balances: balances::Pallet,
25-
@@ -37,4 +38,6 @@ fn main() {
25+
@@ -34,4 +35,6 @@ fn main() {
2626
// second transaction
2727
runtime.system.inc_nonce(&alice);
28-
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{}", e));
28+
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{e}"));
2929
+
3030
+ /* TODO: Print the final runtime state after all transactions. */
3131
}

src/15/source/src/main.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@ fn main() {
3030

3131
// first transaction
3232
runtime.system.inc_nonce(&alice);
33-
let _res = runtime
34-
.balances
35-
.transfer(alice.clone(), bob, 30)
36-
.map_err(|e| eprintln!("{}", e));
33+
let _res = runtime.balances.transfer(alice.clone(), bob, 30).map_err(|e| eprintln!("{e}"));
3734

3835
// second transaction
3936
runtime.system.inc_nonce(&alice);
40-
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{}", e));
37+
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{e}"));
4138

42-
println!("{:#?}", runtime);
39+
println!("{runtime:#?}");
4340
}

src/16/solution/src/main.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,11 @@ fn main() {
3030

3131
// first transaction
3232
runtime.system.inc_nonce(&alice);
33-
let _res = runtime
34-
.balances
35-
.transfer(alice.clone(), bob, 30)
36-
.map_err(|e| eprintln!("{}", e));
33+
let _res = runtime.balances.transfer(alice.clone(), bob, 30).map_err(|e| eprintln!("{e}"));
3734

3835
// second transaction
3936
runtime.system.inc_nonce(&alice);
40-
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{}", e));
37+
let _res = runtime.balances.transfer(alice, charlie, 20).map_err(|e| eprintln!("{e}"));
4138

42-
println!("{:#?}", runtime);
39+
println!("{runtime:#?}");
4340
}

0 commit comments

Comments
 (0)