Add logic for requesting reviews
This commit is contained in:
parent
c88e85f5ff
commit
733659f8ce
1 changed files with 22 additions and 2 deletions
|
@ -18,10 +18,30 @@ impl Post {
|
|||
pub fn content(&self) -> &str {
|
||||
""
|
||||
}
|
||||
|
||||
pub fn request_review(&mut self) {
|
||||
if let Some(s) = self.state.take() {
|
||||
self.state = Some(s.request_review())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait State {}
|
||||
trait State {
|
||||
fn request_review(self: Box<Self>) -> Box<dyn State>;
|
||||
}
|
||||
|
||||
struct Draft {}
|
||||
|
||||
impl State for Draft {}
|
||||
impl State for Draft {
|
||||
fn request_review(self: Box<Self>) -> Box<dyn State> {
|
||||
Box::new(PendingReview {})
|
||||
}
|
||||
}
|
||||
|
||||
struct PendingReview {}
|
||||
|
||||
impl State for PendingReview {
|
||||
fn request_review(self: Box<Self>) -> Box<dyn State> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue