File tree Expand file tree Collapse file tree 1 file changed +31
-10
lines changed Expand file tree Collapse file tree 1 file changed +31
-10
lines changed Original file line number Diff line number Diff line change @@ -384,17 +384,38 @@ void foo(R)(R r)
384
384
if (R == 1)
385
385
-------------------------------
386
386
$(LI Pre and post contracts should have the same indentation level as their
387
- declaration. Put no space between `in`/`out` and an open parenthesis:)
388
- -------------------------------
389
- int foo(int r)
390
- in(r == 0)
391
- out(result; result == 0)
392
- do { … }
387
+ declaration. The expression-based syntax should be preferred when the
388
+ equivalent long-form syntax would have a single `assert` statement.
389
+ Put a space after `in`/`out` similar to `if` constraints:)
390
+ -------------------------------
391
+ // Prefer:
392
+ T transmogrify(T)(T value)
393
+ if (isIntegral!T)
394
+ in (value % 7 == 0)
395
+ out (result; result % 11 == 0)
396
+ {
397
+ // ...
398
+ }
393
399
394
- int foo(int r)
395
- in { … }
396
- out(result) { … }
397
- do { … }
400
+ // over this:
401
+ T transmogrify(T)(T value)
402
+ if (isIntegral!T)
403
+ in { assert(value % 7 == 0); }
404
+ out (result) { assert(result % 11 == 0); }
405
+ do
406
+ {
407
+ // ...
408
+ }
409
+ -------------------------------
410
+ $(LI Invariants should use the expression-based syntax when the equivalent
411
+ long-form syntax would have a single `assert` statement. Put a space
412
+ between `invariant` and the opening parentheses:)
413
+ -------------------------------
414
+ struct S
415
+ {
416
+ int x;
417
+ invariant (x > 0);
418
+ }
398
419
-------------------------------
399
420
)
400
421
$(LISTSECTION phobos_class_struct_field_declaration, Class/Struct Field Declarations,
You can’t perform that action at this time.
0 commit comments