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

SCREAMING-KEBAB-CASE support #1043

Merged
merged 1 commit into from
Sep 9, 2017

Conversation

greyblake
Copy link
Contributor

Hey! Thanks for the nice library =)

Here is a small patch for support of SCREAMING-KEBAB-CASE, that is used in some APIs. Name is inspired by already existing SCREAMING_SNAKE_CASE and kebab-case.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The implementation looks good to me.

Could you point out any public-facing APIs that use this convention? I have never seen this before.

@greyblake
Copy link
Contributor Author

@dtolnay Hey! The one that I am interesting in is Bittrex API.
Example: https://bittrex.com/api/v1.1/public/getmarketsummaries
I agree, it may look weird, but they use market names like BTC-LTC, BTC-ETH, etc. So I thought it would be good to have something like SCREAMING-KEBAB-CASE to parse market names into enum automatically.

@serde-rs serde-rs deleted a comment from clarfonthey Sep 8, 2017
@serde-rs serde-rs deleted a comment from clarfonthey Sep 8, 2017
@serde-rs serde-rs deleted a comment from clarfonthey Sep 8, 2017
@dtolnay
Copy link
Member

dtolnay commented Sep 8, 2017

Thanks for the review @clarcharr. I removed the comments because I don't care about formatting in PRs -- see #438 (comment) for my philosophy.

@greyblake those are values in the JSON, not keys, so to clarify are you deserializing into something like this?

#[derive(Deserialize)]
#[serde(rename_all = "PascalCase")]
struct Summary {
    market_name: MarketName,
    /* other fields */
}

#[derive(Deserialize)]
#[serde(rename_all = "SCREAMING-KEBAB-CASE")]
enum MarketName {
    BtcLtc,
    BtcEth,
}

@greyblake
Copy link
Contributor Author

@dtolnay Yes, those are values. The example you provided is exactly what I do in my code base.

@dtolnay dtolnay merged commit e47284c into serde-rs:master Sep 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants