Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support title cased field names #502

Open
casey opened this issue Feb 25, 2025 · 3 comments
Open

Support title cased field names #502

casey opened this issue Feb 25, 2025 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@casey
Copy link

casey commented Feb 25, 2025

Great library! It would be nice to support title case for table headers, i.e., Upper Title Case and lower title case. If a table is primarily intended for a human reader, I think these are the easiest formats to read.

@zhiburt
Copy link
Owner

zhiburt commented Feb 26, 2025

Hi @casey

I do agree with your proposal.

I hope you have noticed,
we already have support for it we just don't support Upper Tittle Case and lower tittle case.

#[derive(Tabled)]
#[tabled(rename_all = "UPPERCASE")]
struct Country {
    name: String,
    #[tabled(rename_all = "kebab-case")]
    area_km2: f32,
}

But I guess it would be also good to provide same functionality dynamically.
Like the following.

table.modify(Rows::first(), Format::upper_title_case())

@zhiburt zhiburt added enhancement New feature or request good first issue Good for newcomers labels Feb 26, 2025
@zhiburt
Copy link
Owner

zhiburt commented Feb 27, 2025

OK I've committed a derive update.
You can use it on master until it not released.

#[derive(Tabled)]
#[tabled(rename_all = "camelCase")]
struct Country {
    name: String,
    #[tabled(rename_all = "Upper Title Case")]
    capital_city: String,
    #[tabled(rename_all = "lower title case")]
    area_km2: f32,
}

@casey
Copy link
Author

casey commented Feb 28, 2025

Awesome, just tried out the master branch and it looks great. (It's a tool to enumerate audio devices.)

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants