Skip to content

Commit 5b0e54d

Browse files
committed
Allow aggregate replacement constructors
1 parent 6b0c73d commit 5b0e54d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

PRINCIPLES.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,17 @@ This library is an experiment and not intended for use. See the
5757

5858
## Nitty gritty.
5959

60-
1. No public constructors, except for the default constructor. All other
61-
construction is through (named) static methods.
60+
1. No public constructors, except for the default constructor and an aggregate
61+
constructor of all fields. All other construction is through (named) static
62+
methods.
63+
* The aggregate constructor acts like the implicit constructor in cases
64+
where it does not exist. It takes values for and initializes all data
65+
members in the order they are declared.
6266
* Non-default constructors are prefixed with `with_()` unless there's a
6367
clear and better domain-specific name.
64-
* Would like to extend this to Copy and Move constructors too, through `Clone`
65-
and `Move` methods. Implementation details required.
68+
* Avoid writing copy constructors in non-containers unless copying is so
69+
cheap you would pass the argument by value. Instead write Clone.
70+
Containers have a copy constructor if their inner type has one.
6671
* Write a `::from(x)` constructing method to implement
6772
`sus::construct::From` when the type is constructed from another type.
6873
* Exception granted for closure types (Fn, FnMut, FnOnce) because

0 commit comments

Comments
 (0)