Skip to content

Commit 0e85135

Browse files
committed
Nobody actually does this
1 parent a80355d commit 0e85135

File tree

1 file changed

+0
-26
lines changed

1 file changed

+0
-26
lines changed

src/predictability.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -176,32 +176,6 @@ use example::Example;
176176
let ex = Example::new();
177177
```
178178

179-
Constructors for structs with sensible defaults allow clients to concisely
180-
override using the [struct update syntax].
181-
182-
[struct update syntax]: https://doc.rust-lang.org/book/first-edition/structs.html#update-syntax
183-
184-
```rust
185-
pub struct Config {
186-
pub color: Color,
187-
pub size: Size,
188-
pub shape: Shape,
189-
}
190-
191-
impl Config {
192-
pub fn new() -> Config {
193-
Config {
194-
color: Brown,
195-
size: Medium,
196-
shape: Square,
197-
}
198-
}
199-
}
200-
201-
// In user's code.
202-
let config = Config { color: Red, .. Config::new() };
203-
```
204-
205179
The name `new` should generally be used for the primary method of instantiating
206180
a type. Sometimes it takes no arguments, as in the examples above. Sometimes it
207181
does take arguments, like [`Box::new`] which is passed the value to place in the

0 commit comments

Comments
 (0)