diff --git a/pbjson-build/src/descriptor.rs b/pbjson-build/src/descriptor.rs index 6e557f0..7bd5168 100644 --- a/pbjson-build/src/descriptor.rs +++ b/pbjson-build/src/descriptor.rs @@ -21,9 +21,9 @@ pub struct Package { impl Display for Package { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.path[0].to_snake_case())?; + write!(f, "{}", self.path[0].to_snake_case_ident())?; for element in &self.path[1..self.path.len()] { - write!(f, ".{}", element.to_snake_case())?; + write!(f, ".{}", element.to_snake_case_ident())?; } Ok(()) } @@ -68,7 +68,7 @@ impl TypeName { Self(s) } - pub fn to_snake_case(&self) -> String { + pub fn to_snake_case_ident(&self) -> String { use heck::ToSnakeCase; escape_ident(self.0.to_snake_case()) } diff --git a/pbjson-build/src/resolver.rs b/pbjson-build/src/resolver.rs index 5d1d68f..8d9d4bb 100644 --- a/pbjson-build/src/resolver.rs +++ b/pbjson-build/src/resolver.rs @@ -75,7 +75,7 @@ impl<'a> Resolver<'a> { while let Some(i) = iter.next() { match iter.peek() { Some(_) => { - ret.push_str(i.to_snake_case().as_str()); + ret.push_str(i.to_snake_case_ident().as_str()); ret.push_str("::"); } None => {