Skip to content

Commit e333680

Browse files
committed
ensure to have explicit main functions in typestate pattern
1 parent 50244f8 commit e333680

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/idiomatic/leveraging-the-type-system/typestate-pattern.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ impl SerializeStruct {
3232
}
3333
}
3434

35-
let ser = Serializer::default()
36-
.serialize_struct("User")
37-
.serialize_field("id", "42")
38-
.serialize_field("name", "Alice")
39-
.finish_struct();
40-
println!("{}", ser.output);
35+
fn main() {
36+
let ser = Serializer::default()
37+
.serialize_struct("User")
38+
.serialize_field("id", "42")
39+
.serialize_field("name", "Alice")
40+
.finish_struct();
41+
println!("{}", ser.output);
42+
}
4143
```
4244

4345
<details>

src/idiomatic/leveraging-the-type-system/typestate-pattern/typestate-generics.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ shared logic across state variants, while still encoding state transitions in
55
the type system.
66

77
```rust
8-
# fn main() -> std::io::Result<()> {
98
#[non_exhaustive]
109
struct Insecure;
1110
struct Secure {
@@ -85,13 +84,14 @@ impl<T: Transport> ConnectionBuilder<Ready<T>> {
8584
}
8685
}
8786

88-
let _conn = Connection::new("db.local")
89-
.secure()
90-
.client_certificate(vec![1, 2, 3])
91-
.timeout(10)
92-
.connect()?;
93-
Ok(())
94-
# }
87+
fn main() -> std::io::Result<()> {
88+
let _conn = Connection::new("db.local")
89+
.secure()
90+
.client_certificate(vec![1, 2, 3])
91+
.timeout(10)
92+
.connect()?;
93+
Ok(())
94+
}
9595
```
9696

9797
<details>

0 commit comments

Comments
 (0)