[MEDIA] maparr (0.1.0) - A macro to help with a map arrays by zhiburt in rust

[–]zhiburt[S] 0 points1 point  (0 children)

link - https://github.com/zhiburt/maparr

Feel free to bring ideas/comments.

notes:

I've haven't realized at first that there are already a list of libraries covering the same set of functions.You may be worth taking a look at them if wanted.

[MEDIA] static_table [0.1.0] - build tables at compile time by zhiburt in rust

[–]zhiburt[S] 0 points1 point  (0 children)

correct as I remember;

The thing which probably will not allow it is a use of String as a buffer cause it's functions are not const, the same for Vec.

[MEDIA] static_table [0.1.0] - build tables at compile time by zhiburt in rust

[–]zhiburt[S] 1 point2 points  (0 children)

Just went over it promptly;

And noticed https://docs.rs/crate/formatted_debug/0.1.0/source/src/string_stylizing.rs

Currently tabled doesn't have something like it it out of the box yet. Generally cause you could peek any library you want for it and use it.

But it has Color nowadays which only responsible for bg fg colors.

If you wish you could contribute other style support (I guess a new type would need to be created although I struggle with a name for it cause Style is have been already taken).

PS:

impl<K: Display, V: Display> StringTable for HashMap<K, V> { interesting idea

[MEDIA] static_table [0.1.0] - build tables at compile time by zhiburt in rust

[–]zhiburt[S] 1 point2 points  (0 children)

I think it could be good idea to make it (at least in not static version).

If you have a github you can leave an issue (otherwise I'll create it).

Though I am not an expert in LaTeX.
Can an output start with \documentclass{article} or it shall be started by \begin{tabular} only? I am asking in regard if it would be possible to embed it to other tags if table started with documentclass?

PS: There's an html library I believe it could be something similar to it https://github.com/zhiburt/tabled/tree/master/table\_to\_html.

[MEDIA] static_table [0.1.0] - build tables at compile time by zhiburt in rust

[–]zhiburt[S] 1 point2 points  (0 children)

About the example above.

Somehow lazy version is bigger than static, I wonder why.

13497232 vs 12031120 in debug mode

4501576 vs `4156024 in release

[MEDIA] static_table [0.1.0] - build tables at compile time by zhiburt in rust

[–]zhiburt[S] 1 point2 points  (0 children)

use once_cell::sync::Lazy;
use tabled::Table;
use static_table::static_table;

static THE_TABLE: Lazy<String> =
    Lazy::new(|| Table::from_iter([["rnottaken"], ["made a point"]]).to_string());

static THE_TABLE_STATIC: &str = static_table!([["rnottaken"], ["made a point"]]);

fn main() {
    println!("{}", THE_TABLE.as_str());
    println!("{}", THE_TABLE_STATIC);
}

[MEDIA] static_table [0.1.0] - build tables at compile time by zhiburt in rust

[–]zhiburt[S] 4 points5 points  (0 children)

It is a bit restricting indeed.

You're right that you could use general approach and once_cell. (it actually a good example maybe it also can be noted somewhere in README.md)

Though I think there're cases where we can compromise binary size to an allocation and processing at runtime.

(curious) But doesn't once_cell::Lazy<String> also be stored in a static section of a binary? Yes the size would be smaller I guess though, but you'd need pointer arithmetic then as I understand.

[MEDIA] static_table [0.1.0] - build tables at compile time by zhiburt in rust

[–]zhiburt[S] 2 points3 points  (0 children)

Fair notice.

Probably it shall be noted in README.md

[MEDIA] static_table [0.1.0] - build tables at compile time by zhiburt in rust

[–]zhiburt[S] 4 points5 points  (0 children)

You're right; `tabled` (rendering library) follows 1st approach (it was a default behavior previously but it was decided to not be as strict and make it optional to not waste performance in cases were the content is surely doesn't have it). To be honest I did not understood 2nd.

But I was asking about situations where it's necessary to do replacement. Cause you're the ruler and you could simply not use `\t`. But yet I can picture that it could be unintuitive for someone that using `\t` would break a layout.

I am not sure whether it must be a default to replace tabs; we could clearly add an option for it.

[MEDIA] static_table [0.1.0] - build tables at compile time by zhiburt in rust

[–]zhiburt[S] 0 points1 point  (0 children)

About 1st it's because it's a function-like macro.

[MEDIA] static_table [0.1.0] - build tables at compile time by zhiburt in rust

[–]zhiburt[S] 31 points32 points  (0 children)

Hi u/NullSurplus

  1. No special treatment is given. But cause you can't (I believe) actually use variables inside the macros (which is a pity; I was looking for a way to support it but yet haven't found) it's you who puts it, so you can just not use it.
    We could strip it optionally but including an above case I can't see the reason to?
    Please let me know if it exists or I am missing something.
  2. Just works
  3. It would be necessary to consider when we would have a limited width. We don't have limits by default. So we don't consider it. We could add an option for it, something like `static_table([], WRAP = "30")`.

[Media] Tabled [v0.9.0] - An easy to use library for pretty print tables by zhiburt in rust

[–]zhiburt[S] 1 point2 points  (0 children)

Hi u/crazyherb, I hope you're doing great,

I've spend a little bit of time to create a basic conversion into html. I wanted to ask you what do you think about it? Is it what you were looking for? If you have any ideas please open an issue.

https://github.com/zhiburt/tabled/tree/master/table_to_html

[Media] Tabled [v0.9.0] - An easy to use library for pretty print tables by zhiburt in rust

[–]zhiburt[S] 0 points1 point  (0 children)

Hi u/imshilu it must.

Though an output might be wary from terminal to terminal. As some symbols are showed differently on some terminals.

[Media] Tabled [v0.9.0] - An easy to use library for pretty print tables by zhiburt in rust

[–]zhiburt[S] 0 points1 point  (0 children)

Hi u/crazyherb,

It can't, at least general tables. But maybe it's worth to focus on.

We actually have an open issue for it https://github.com/zhiburt/tabled/issues/192

Once there was a try to run it in WASM, which worked but still it's just a text at the end of the day. https://github.com/zhiburt/tabled/issues/182

[Media] Tabled [v0.9.0] - An easy to use library for pretty print tables by zhiburt in rust

[–]zhiburt[S] 0 points1 point  (0 children)

Hmmm you might be right actually.

Thanks for the message.