mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
795 B
49 lines
795 B
pub struct Post {
|
|
content: String,
|
|
}
|
|
|
|
pub struct DraftPost {
|
|
content: String,
|
|
}
|
|
|
|
impl Post {
|
|
pub fn new() -> DraftPost {
|
|
DraftPost {
|
|
content: String::new(),
|
|
}
|
|
}
|
|
|
|
pub fn content(&self) -> &str {
|
|
&self.content
|
|
}
|
|
}
|
|
|
|
// ANCHOR: here
|
|
impl DraftPost {
|
|
// --snip--
|
|
// ANCHOR_END: here
|
|
pub fn add_text(&mut self, text: &str) {
|
|
self.content.push_str(text);
|
|
}
|
|
|
|
// ANCHOR: here
|
|
pub fn request_review(self) -> PendingReviewPost {
|
|
PendingReviewPost {
|
|
content: self.content,
|
|
}
|
|
}
|
|
}
|
|
|
|
pub struct PendingReviewPost {
|
|
content: String,
|
|
}
|
|
|
|
impl PendingReviewPost {
|
|
pub fn approve(self) -> Post {
|
|
Post {
|
|
content: self.content,
|
|
}
|
|
}
|
|
}
|
|
// ANCHOR_END: here
|