Crates.io | static_table |
lib.rs | static_table |
version | 0.3.0 |
source | src |
created_at | 2023-04-11 23:11:04.82959 |
updated_at | 2023-12-20 01:41:01.875152 |
description | Library creates pretty tables at compiler time |
homepage | https://github.com/zhiburt/tabled |
repository | https://github.com/zhiburt/tabled |
max_upload_size | |
id | 836409 |
size | 89,627 |
static_table
) Cook tables at compiler timeThe library provides a macros to build a pretty tables at compile time.
There's 2 types of tables you can buid.
static_table::static_table
).static_table::pool_table
).To find a more features and settings which you can use with the macros please check out the documentation (docs.rs).
Add the library to your Cargo.toml
.
# Cargo.toml
[dependencies]
static_table = "0.2"
An example of static_table
usage.
Example | Result |
---|---|
|
|
An example of pool_table
usage.
Example | Result |
---|---|
|
|
You can even use the macros in the documentation
/// Add joins 2 integers together to get a sum.
///
/// ```
#[doc = static_table::static_table!([
["a", "b", "result"],
["1", '2', '3'],
["2", '2', '4']
])]
/// ```
pub fn add(left: usize, right: usize) -> usize {
left + right
}
It's something you shall be aware of.
Using static_table
MIGHT increase a binary size, because the table will be stored as actuall symbols in a static section of a binary file (ELF, PE etc.).
I have run a few tests in this regard.
And a binary which used static_table
has SUBSTATIANALY smaller size than
a binary with a build table at runtime using lazy_static
/once_cell
.
I am not sure though why it is a case.
debug mode release mode
static_table 13497232 4501576
runtime table 12031120 4156024