mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2025-02-25 05:42:18 +08:00
20 lines
288 B
Rust
Executable File
20 lines
288 B
Rust
Executable File
pub struct Post {
|
|
state: Option<Box<dyn State>>,
|
|
content: String,
|
|
}
|
|
|
|
impl Post {
|
|
pub fn new() -> Post {
|
|
Post {
|
|
state: Some(Box::new(Draft {})),
|
|
content: String::new(),
|
|
}
|
|
}
|
|
}
|
|
|
|
trait State {}
|
|
|
|
struct Draft {}
|
|
|
|
impl State for Draft {}
|