web/form_render/
without.rs1use forms::{Field, Form};
4
5const fn same(a: &str, b: &str) -> bool {
6 let (a, b) = (a.as_bytes(), b.as_bytes());
7 if a.len() != b.len() {
8 return false;
9 }
10 let mut i = 0;
11 while i < a.len() {
12 if a[i] != b[i] {
13 return false;
14 }
15 i += 1;
16 }
17 true
18}
19
20#[must_use]
23pub const fn without<const N: usize>(form: &Form, key: &str) -> [Field; N] {
24 let mut out = [form.fields[0]; N];
25 let mut kept = 0;
26 let mut i = 0;
27 while i < form.fields.len() {
28 if !same(form.fields[i].key, key) {
29 out[kept] = form.fields[i];
30 kept += 1;
31 }
32 i += 1;
33 }
34 assert!(kept == N);
35 out
36}