Add a blog
crate for demonstrating states
This commit is contained in:
parent
cbbf0bb596
commit
f924172cb4
4 changed files with 35 additions and 0 deletions
7
blog/Cargo.lock
generated
Normal file
7
blog/Cargo.lock
generated
Normal file
|
@ -0,0 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "blog"
|
||||
version = "0.1.0"
|
6
blog/Cargo.toml
Normal file
6
blog/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "blog"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
19
blog/src/lib.rs
Normal file
19
blog/src/lib.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
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 {}
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "./blog"
|
||||
},
|
||||
{
|
||||
"path": "./gui"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue