Example: Section Start
This is how the Gitorial mdBook Template is rendered.
This page is a "Section Start", so there is no code being rendered, just the README
text.
Go to the next page to see other examples of how pages are rendered.
Example: New Files
In this page, we introduce new files to the Gitorial: Cargo.toml
and src/main.rs
.
These come from cargo init
.
You can see how the mdBook renders that new content, and shows a diff
of the new files.
[package]
name = "rust-state-machine"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
fn main() { println!("Hello, world!"); }
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..400485bd
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+**/target/
+.DS_Store
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 00000000..75fe297f
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "rust-state-machine"
+version = "0.1.0"
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 00000000..c7fe36cd
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "rust-state-machine"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 00000000..e7a11a96
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!("Hello, world!");
+}
Example: Modified Files
On this page you can see we modify the indentation src/main.rs
file, and that modified file is colored orange.
# Basic
edition = "2021"
hard_tabs = true
max_width = 100
use_small_heuristics = "Max"
# Imports
imports_granularity = "Crate"
reorder_imports = true
# Consistency
newline_style = "Unix"
# Misc
chain_width = 80
spaces_around_ranges = false
binop_separator = "Back"
reorder_impl_items = false
match_arm_leading_pipes = "Preserve"
match_arm_blocks = false
match_block_trailing_comma = true
trailing_comma = "Vertical"
trailing_semicolon = false
use_field_init_shorthand = true
# Format comments
comment_width = 100
wrap_comments = true
fn main() { println!("Hello, world!"); }
diff --git a/rustfmt.toml b/rustfmt.toml
new file mode 100644
index 00000000..c3421539
--- /dev/null
+++ b/rustfmt.toml
@@ -0,0 +1,24 @@
+# Basic
+edition = "2021"
+hard_tabs = true
+max_width = 100
+use_small_heuristics = "Max"
+# Imports
+imports_granularity = "Crate"
+reorder_imports = true
+# Consistency
+newline_style = "Unix"
+# Misc
+chain_width = 80
+spaces_around_ranges = false
+binop_separator = "Back"
+reorder_impl_items = false
+match_arm_leading_pipes = "Preserve"
+match_arm_blocks = false
+match_block_trailing_comma = true
+trailing_comma = "Vertical"
+trailing_semicolon = false
+use_field_init_shorthand = true
+# Format comments
+comment_width = 100
+wrap_comments = true
diff --git a/src/main.rs b/src/main.rs
index e7a11a96..a30eb952 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,3 @@
fn main() {
- println!("Hello, world!");
+ println!("Hello, world!");
}
Template README
This is the README
file located in the template
folder.
This file is rendered and shown to the reader.
In the code section, you can see a template
tab with the TODO
action items for the reader, and the solution
tab with the solution to the template
.
#![allow(unused)] fn main() { /* TODO: create a new public struct named `Pallet`. */ }
/* TODO: use your new module `balances` */ fn main() { println!("Hello, world!"); }
#![allow(unused)] fn main() { pub struct Pallet {} }
mod balances; fn main() { println!("Hello, world!"); }
diff --git a/src/balances.rs b/src/balances.rs
new file mode 100644
index 00000000..dae1c4f1
--- /dev/null
+++ b/src/balances.rs
@@ -0,0 +1 @@
+/* TODO: create a new public struct named `Pallet`. */
diff --git a/src/main.rs b/src/main.rs
index a30eb952..2b4f7670 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,5 @@
+/* TODO: use your new module `balances` */
+
fn main() {
println!("Hello, world!");
}
diff --git a/src/balances.rs b/src/balances.rs
index dae1c4f1..4a1da04e 100644
--- a/src/balances.rs
+++ b/src/balances.rs
@@ -1 +1 @@
-/* TODO: create a new public struct named `Pallet`. */
+pub struct Pallet {}
diff --git a/src/main.rs b/src/main.rs
index 2b4f7670..ea8024e5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,4 @@
-/* TODO: use your new module `balances` */
+mod balances;
fn main() {
println!("Hello, world!");