1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//! A shape's identity: the ordinal a figure is drawn under and a buffer records beside the cells it
//! decided. See _Stamping_ in [`docs/model.md`](../../../docs/model.md).
//!
//! # Design notes
//!
//! **The type is an ordinal and holds no rule about a diagram.** Who issues an identity, whether two
//! may share one and what may be done with it are all questions about a diagram rather than about a
//! number, and they stay with the diagram — see _Identity_ in
//! [`docs/diagram-model.md`](../../../docs/diagram-model.md). What is left here is the one thing
//! the core has to hold: a number it can compare and write down.
//!
//! **The one rule it does hold is about the value rather than about any diagram.** Zero is not an
//! identity, so the ordinal is a [`NonZeroU16`] and [`ShapeId::new`] is the way in. That is a
//! narrower claim than the issuing and uniqueness questions above, and the distinction is what puts
//! it here: no diagram ever issued a `0`, and a diagram seeded at `1` says so.
//!
//! **Two bytes that are `Copy` rather than a string.** A buffer records one identity per stamped
//! position, so the width is paid for once per stamped cell and once per figure a diagram holds:
//! `u16` is 65 535 figures, and an ordinal is compared, copied and stored without an allocation; a
//! borrowed `&ShapeId` per position would put a lifetime in front of every caller to save nothing.
//!
//! **A module of its own rather than a line in `geometry`.** `Pos`, `Size`, `Direction` and
//! `Orientation` are places and amounts on the plane, and an identity is neither — putting the two
//! in one file would give the identity a neighbor it has nothing to say to. [`crate::stroke`] is
//! the precedent: one type, one module.
use fmt;
use NonZeroU16;
/// A shape's identity: the ordinal a figure is drawn under, and what a buffer records beside each
/// cell that figure decided.
///
/// Built from its ordinal by [`ShapeId::new`] and written back out as the bare number, `1` and `2`
/// and so on. It is `Copy`, and it carries one rule of its own: zero is not an identity.
;