mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2024-11-09 00:43:59 +08:00
Update ch17-03-oo-design-patterns.md
This commit is contained in:
parent
72e6b9b860
commit
209019a508
@ -73,7 +73,7 @@ impl State for Draft {}
|
||||
|
||||
当我们创建一个新的`Post`实例时, 我们把它的`state`字段设为一个`Some`类型的值, 该值持有指向一个新的`Draft`结构实例的`Box`. 这就确保无论何时我们创建一个`Post`类型的新实例时, 它总是处于草稿状态. 因为`Post`的`state`字段是私有的, 除了调用`new`无法创建一个处于其它状态的`Post`!
|
||||
|
||||
### Storing the Text of the Post Content
|
||||
### 存放Post的文本内容
|
||||
|
||||
In the `Post::new` function, we set the `content` field to a new, empty
|
||||
`String`. In Listing 17-11, we showed that we want to be able to call a method
|
||||
|
Loading…
Reference in New Issue
Block a user