Skip to main content

forms/
address.rs

1//! Field addresses: a flat field is its key, row `i` of a `rows` field is
2//! `key.i` and a cell of that row is `key.i.sub`. The index is any display,
3//! so a template row can carry a placeholder.
4
5use std::fmt::Display;
6
7/// The address of row `index` of the `rows` field `key`.
8#[must_use]
9pub fn row(key: &str, index: impl Display) -> String {
10    format!("{key}.{index}")
11}
12
13/// The address of cell `sub` in row `index` of the `rows` field `key`.
14#[must_use]
15pub fn cell(key: &str, index: impl Display, sub: &str) -> String {
16    format!("{key}.{index}.{sub}")
17}