Reuse table_formatting logic for almost everything (#39)

This commit is contained in:
huynd2001 2024-03-09 23:01:44 -05:00 committed by GitHub
parent 54426ed477
commit 13683aa229
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 273 additions and 388 deletions

View file

@ -17,9 +17,9 @@ impl Align {
}
}
pub fn table_formatting<const N: usize, S: AsRef<str> + std::fmt::Debug, Ts: AsRef<[[S; N]]>>(
headers: &[&'static str; N],
padding: &[Align; N],
pub fn table_formatting_unsafe<S: AsRef<str> + std::fmt::Debug, Ss: AsRef<[S]>, Ts: AsRef<[Ss]>>(
headers: &[&str],
padding: &[Align],
table: Ts,
) -> String {
let table = table.as_ref();
@ -68,3 +68,11 @@ pub fn table_formatting<const N: usize, S: AsRef<str> + std::fmt::Debug, Ts: AsR
m.push("```");
m.build()
}
pub fn table_formatting<const N: usize, S: AsRef<str> + std::fmt::Debug, Ts: AsRef<[[S; N]]>>(
headers: &[&'static str; N],
padding: &[Align; N],
table: Ts,
) -> String {
table_formatting_unsafe(headers, padding, table)
}