You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/coding-guidelines/types-and-traits.rst
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Types and Traits
7
7
================
8
8
9
9
.. guideline:: Use strong types to differentiate between logically distinct values
10
-
:id:gui_xztNdXA2oFNB
10
+
:id:gui_xztNdXA2oFNC
11
11
:category: advisory
12
12
:status: draft
13
13
:release: 1.85.0;1.85.1
@@ -27,7 +27,7 @@ Types and Traits
27
27
* You need to establish new invariants
28
28
29
29
.. rationale::
30
-
:id:rat_kYiIiW8R2qD1
30
+
:id:rat_kYiIiW8R2qD2
31
31
:status: draft
32
32
33
33
This rule ensures that parameters and variables convey intent directly through the type system to avoid accidental misuse of values with identical primitives but different semantics.
@@ -49,7 +49,7 @@ Types and Traits
49
49
Statically distinct types act as strong API contracts that can evolve independently from their underlying representations.
50
50
51
51
.. non_compliant_example::
52
-
:id:non_compl_ex_PO5TyFsRTlWv
52
+
:id:non_compl_ex_PO5TyFsRTlWw
53
53
:status: draft
54
54
55
55
This noncompliant example uses primitive types directly, leading to potential confusion between ``distance`` and ``time``.
@@ -70,7 +70,7 @@ Types and Traits
70
70
}
71
71
72
72
.. non_compliant_example::
73
-
:id:non_compl_ex_PO5TyFsRTlWu
73
+
:id:non_compl_ex_PO5TyFsRTlWv
74
74
:status: draft
75
75
76
76
This noncompliant example uses aliases instead of distinct types.
@@ -99,7 +99,7 @@ Types and Traits
99
99
}
100
100
101
101
.. compliant_example::
102
-
:id:compl_ex_WTe7GoPu5Ez0
102
+
:id:compl_ex_WTe7GoPu5Ez1
103
103
:status: draft
104
104
105
105
This compliant example uses newtypes to create distinct types for ``Meters``, ``Seconds``, and ``MetersPerSecond``.
0 commit comments