You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-08-08 08:22:52 +02:00
ensure to have explicit main functions in typestate pattern
This commit is contained in:
@ -32,12 +32,14 @@ impl SerializeStruct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let ser = Serializer::default()
|
fn main() {
|
||||||
|
let ser = Serializer::default()
|
||||||
.serialize_struct("User")
|
.serialize_struct("User")
|
||||||
.serialize_field("id", "42")
|
.serialize_field("id", "42")
|
||||||
.serialize_field("name", "Alice")
|
.serialize_field("name", "Alice")
|
||||||
.finish_struct();
|
.finish_struct();
|
||||||
println!("{}", ser.output);
|
println!("{}", ser.output);
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
@ -5,7 +5,6 @@ shared logic across state variants, while still encoding state transitions in
|
|||||||
the type system.
|
the type system.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
# fn main() -> std::io::Result<()> {
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
struct Insecure;
|
struct Insecure;
|
||||||
struct Secure {
|
struct Secure {
|
||||||
@ -85,13 +84,14 @@ impl<T: Transport> ConnectionBuilder<Ready<T>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let _conn = Connection::new("db.local")
|
fn main() -> std::io::Result<()> {
|
||||||
|
let _conn = Connection::new("db.local")
|
||||||
.secure()
|
.secure()
|
||||||
.client_certificate(vec![1, 2, 3])
|
.client_certificate(vec![1, 2, 3])
|
||||||
.timeout(10)
|
.timeout(10)
|
||||||
.connect()?;
|
.connect()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
# }
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
Reference in New Issue
Block a user