diff --git a/blog/Cargo.lock b/blog/Cargo.lock new file mode 100644 index 0000000..4bcdaea --- /dev/null +++ b/blog/Cargo.lock @@ -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" diff --git a/blog/Cargo.toml b/blog/Cargo.toml new file mode 100644 index 0000000..790832e --- /dev/null +++ b/blog/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "blog" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/blog/src/lib.rs b/blog/src/lib.rs new file mode 100644 index 0000000..b8156c3 --- /dev/null +++ b/blog/src/lib.rs @@ -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 {} diff --git a/rust-exercises.code-workspace b/rust-exercises.code-workspace index 8c1d517..df838b8 100644 --- a/rust-exercises.code-workspace +++ b/rust-exercises.code-workspace @@ -1,5 +1,8 @@ { "folders": [ + { + "path": "./blog" + }, { "path": "./gui" },