Skip to content

Commit

Permalink
Merge pull request #21 from influxdata/dependabot/cargo/heck-0.4
Browse files Browse the repository at this point in the history
chore(deps): update heck requirement from 0.3 to 0.4
  • Loading branch information
kodiakhq[bot] authored Feb 13, 2022
2 parents bd227c5 + 8d0fbbc commit 1451ba8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pbjson-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/influxdata/pbjson"

[dependencies]

heck = "0.3"
heck = "0.4"
prost = "0.9"
prost-types = "0.9"
itertools = "0.10"
Expand Down
8 changes: 4 additions & 4 deletions pbjson-build/src/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ impl TypeName {
}

pub fn to_snake_case(&self) -> String {
use heck::SnakeCase;
use heck::ToSnakeCase;
self.0.to_snake_case()
}

pub fn to_camel_case(&self) -> String {
use heck::CamelCase;
self.0.to_camel_case()
pub fn to_upper_camel_case(&self) -> String {
use heck::ToUpperCamelCase;
self.0.to_upper_camel_case()
}
}

Expand Down
12 changes: 6 additions & 6 deletions pbjson-build/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,20 @@ pub struct Field {

impl Field {
pub fn rust_type_name(&self) -> String {
use heck::CamelCase;
self.name.to_camel_case()
use heck::ToUpperCamelCase;
self.name.to_upper_camel_case()
}

pub fn rust_field_name(&self) -> String {
use heck::SnakeCase;
use heck::ToSnakeCase;
escape_ident(self.name.to_snake_case())
}

pub fn json_name(&self) -> String {
use heck::MixedCase;
use heck::ToLowerCamelCase;
self.json_name
.clone()
.unwrap_or_else(|| self.name.to_mixed_case())
.unwrap_or_else(|| self.name.to_lower_camel_case())
}
}

Expand All @@ -111,7 +111,7 @@ pub struct OneOf {

impl OneOf {
pub fn rust_field_name(&self) -> String {
use heck::SnakeCase;
use heck::ToSnakeCase;
escape_ident(self.name.to_snake_case())
}
}
Expand Down
8 changes: 4 additions & 4 deletions pbjson-build/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ impl<'a> Resolver<'a> {
ret.push_str("::");
}
None => {
ret.push_str(i.to_camel_case().as_str());
ret.push_str(i.to_upper_camel_case().as_str());
}
}
}
ret
}

pub fn rust_variant(&self, enumeration: &TypePath, variant: &str) -> String {
use heck::CamelCase;
let variant = variant.to_camel_case();
use heck::ToUpperCamelCase;
let variant = variant.to_upper_camel_case();
match self.retain_enum_prefix {
true => variant,
false => {
let prefix = enumeration.path().last().unwrap().to_camel_case();
let prefix = enumeration.path().last().unwrap().to_upper_camel_case();
let stripped = variant.strip_prefix(&prefix).unwrap_or(&variant);

// "Foo" should not be stripped from "Foobar".
Expand Down

0 comments on commit 1451ba8

Please sign in to comment.