Constructs a name by appending a numeric component to `pre`.
(pre: Name, n: Nat)
| 172 | |
| 173 | /// Constructs a name by appending a numeric component to `pre`. |
| 174 | pub fn num(pre: Name, n: Nat) -> Name { |
| 175 | let mut hasher = blake3::Hasher::new(); |
| 176 | hasher.update(&[NNUM]); |
| 177 | hasher.update(pre.get_hash().as_bytes()); |
| 178 | hasher.update(&n.to_le_bytes()); |
| 179 | let hash = hasher.finalize(); |
| 180 | Name(Arc::new(NameData::Num(pre, n, hash))) |
| 181 | } |
| 182 | /// Decompose this name into its components (from root to leaf). |
| 183 | pub fn components(&self) -> Vec<NameComponent> { |
| 184 | let mut components = Vec::new(); |