Skip to content

Commit

Permalink
fully qualify types and traits (#647)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahl authored Aug 8, 2024
1 parent fe57b80 commit 01f3e26
Show file tree
Hide file tree
Showing 29 changed files with 4,449 additions and 4,318 deletions.
38 changes: 19 additions & 19 deletions cargo-typify/tests/outputs/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
#[doc = r" Error types."]
pub mod error {
#[doc = r" Error from a TryFrom or FromStr implementation."]
pub struct ConversionError(std::borrow::Cow<'static, str>);
impl std::error::Error for ConversionError {}
impl std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
std::fmt::Display::fmt(&self.0, f)
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
std::fmt::Debug::fmt(&self.0, f)
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
Expand All @@ -39,15 +39,15 @@ pub mod error {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(Clone, Debug, serde :: Deserialize, serde :: Serialize)]
pub struct Fruit(pub serde_json::Map<String, serde_json::Value>);
impl std::ops::Deref for Fruit {
type Target = serde_json::Map<String, serde_json::Value>;
fn deref(&self) -> &serde_json::Map<String, serde_json::Value> {
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
pub struct Fruit(pub ::serde_json::Map<String, ::serde_json::Value>);
impl ::std::ops::Deref for Fruit {
type Target = ::serde_json::Map<String, ::serde_json::Value>;
fn deref(&self) -> &::serde_json::Map<String, ::serde_json::Value> {
&self.0
}
}
impl From<Fruit> for serde_json::Map<String, serde_json::Value> {
impl From<Fruit> for ::serde_json::Map<String, ::serde_json::Value> {
fn from(value: Fruit) -> Self {
value.0
}
Expand All @@ -57,8 +57,8 @@ impl From<&Fruit> for Fruit {
value.clone()
}
}
impl From<serde_json::Map<String, serde_json::Value>> for Fruit {
fn from(value: serde_json::Map<String, serde_json::Value>) -> Self {
impl From<::serde_json::Map<String, ::serde_json::Value>> for Fruit {
fn from(value: ::serde_json::Map<String, ::serde_json::Value>) -> Self {
Self(value)
}
}
Expand Down Expand Up @@ -89,7 +89,7 @@ impl From<serde_json::Map<String, serde_json::Value>> for Fruit {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(Clone, Debug, serde :: Deserialize, serde :: Serialize)]
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum FruitOrVeg {
Veg(Veggie),
Expand Down Expand Up @@ -134,7 +134,7 @@ impl From<Fruit> for FruitOrVeg {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(Clone, Debug, serde :: Deserialize, serde :: Serialize)]
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
pub struct Veggie {
#[doc = "Do I like this vegetable?"]
#[serde(rename = "veggieLike")]
Expand Down Expand Up @@ -180,7 +180,7 @@ impl Veggie {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(Clone, Debug, serde :: Deserialize, serde :: Serialize)]
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
pub struct Veggies {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub fruits: Vec<String>,
Expand Down
38 changes: 19 additions & 19 deletions cargo-typify/tests/outputs/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
#[doc = r" Error types."]
pub mod error {
#[doc = r" Error from a TryFrom or FromStr implementation."]
pub struct ConversionError(std::borrow::Cow<'static, str>);
impl std::error::Error for ConversionError {}
impl std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
std::fmt::Display::fmt(&self.0, f)
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
std::fmt::Debug::fmt(&self.0, f)
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
Expand All @@ -39,15 +39,15 @@ pub mod error {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(Clone, Debug, ExtraDerive, serde :: Deserialize, serde :: Serialize)]
pub struct Fruit(pub serde_json::Map<String, serde_json::Value>);
impl std::ops::Deref for Fruit {
type Target = serde_json::Map<String, serde_json::Value>;
fn deref(&self) -> &serde_json::Map<String, serde_json::Value> {
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, ExtraDerive)]
pub struct Fruit(pub ::serde_json::Map<String, ::serde_json::Value>);
impl ::std::ops::Deref for Fruit {
type Target = ::serde_json::Map<String, ::serde_json::Value>;
fn deref(&self) -> &::serde_json::Map<String, ::serde_json::Value> {
&self.0
}
}
impl From<Fruit> for serde_json::Map<String, serde_json::Value> {
impl From<Fruit> for ::serde_json::Map<String, ::serde_json::Value> {
fn from(value: Fruit) -> Self {
value.0
}
Expand All @@ -57,8 +57,8 @@ impl From<&Fruit> for Fruit {
value.clone()
}
}
impl From<serde_json::Map<String, serde_json::Value>> for Fruit {
fn from(value: serde_json::Map<String, serde_json::Value>) -> Self {
impl From<::serde_json::Map<String, ::serde_json::Value>> for Fruit {
fn from(value: ::serde_json::Map<String, ::serde_json::Value>) -> Self {
Self(value)
}
}
Expand Down Expand Up @@ -89,7 +89,7 @@ impl From<serde_json::Map<String, serde_json::Value>> for Fruit {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(Clone, Debug, ExtraDerive, serde :: Deserialize, serde :: Serialize)]
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, ExtraDerive)]
#[serde(untagged)]
pub enum FruitOrVeg {
Veg(Veggie),
Expand Down Expand Up @@ -134,7 +134,7 @@ impl From<Fruit> for FruitOrVeg {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(Clone, Debug, ExtraDerive, serde :: Deserialize, serde :: Serialize)]
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, ExtraDerive)]
pub struct Veggie {
#[doc = "Do I like this vegetable?"]
#[serde(rename = "veggieLike")]
Expand Down Expand Up @@ -175,7 +175,7 @@ impl From<&Veggie> for Veggie {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(Clone, Debug, ExtraDerive, serde :: Deserialize, serde :: Serialize)]
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, ExtraDerive)]
pub struct Veggies {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub fruits: Vec<String>,
Expand Down
46 changes: 27 additions & 19 deletions cargo-typify/tests/outputs/multi_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
#[doc = r" Error types."]
pub mod error {
#[doc = r" Error from a TryFrom or FromStr implementation."]
pub struct ConversionError(std::borrow::Cow<'static, str>);
impl std::error::Error for ConversionError {}
impl std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
std::fmt::Display::fmt(&self.0, f)
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
std::fmt::Debug::fmt(&self.0, f)
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
Expand All @@ -39,15 +39,17 @@ pub mod error {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(AnotherDerive, Clone, Debug, ExtraDerive, serde :: Deserialize, serde :: Serialize)]
pub struct Fruit(pub serde_json::Map<String, serde_json::Value>);
impl std::ops::Deref for Fruit {
type Target = serde_json::Map<String, serde_json::Value>;
fn deref(&self) -> &serde_json::Map<String, serde_json::Value> {
#[derive(
:: serde :: Deserialize, :: serde :: Serialize, AnotherDerive, Clone, Debug, ExtraDerive,
)]
pub struct Fruit(pub ::serde_json::Map<String, ::serde_json::Value>);
impl ::std::ops::Deref for Fruit {
type Target = ::serde_json::Map<String, ::serde_json::Value>;
fn deref(&self) -> &::serde_json::Map<String, ::serde_json::Value> {
&self.0
}
}
impl From<Fruit> for serde_json::Map<String, serde_json::Value> {
impl From<Fruit> for ::serde_json::Map<String, ::serde_json::Value> {
fn from(value: Fruit) -> Self {
value.0
}
Expand All @@ -57,8 +59,8 @@ impl From<&Fruit> for Fruit {
value.clone()
}
}
impl From<serde_json::Map<String, serde_json::Value>> for Fruit {
fn from(value: serde_json::Map<String, serde_json::Value>) -> Self {
impl From<::serde_json::Map<String, ::serde_json::Value>> for Fruit {
fn from(value: ::serde_json::Map<String, ::serde_json::Value>) -> Self {
Self(value)
}
}
Expand Down Expand Up @@ -89,7 +91,9 @@ impl From<serde_json::Map<String, serde_json::Value>> for Fruit {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(AnotherDerive, Clone, Debug, ExtraDerive, serde :: Deserialize, serde :: Serialize)]
#[derive(
:: serde :: Deserialize, :: serde :: Serialize, AnotherDerive, Clone, Debug, ExtraDerive,
)]
#[serde(untagged)]
pub enum FruitOrVeg {
Veg(Veggie),
Expand Down Expand Up @@ -134,7 +138,9 @@ impl From<Fruit> for FruitOrVeg {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(AnotherDerive, Clone, Debug, ExtraDerive, serde :: Deserialize, serde :: Serialize)]
#[derive(
:: serde :: Deserialize, :: serde :: Serialize, AnotherDerive, Clone, Debug, ExtraDerive,
)]
pub struct Veggie {
#[doc = "Do I like this vegetable?"]
#[serde(rename = "veggieLike")]
Expand Down Expand Up @@ -175,7 +181,9 @@ impl From<&Veggie> for Veggie {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(AnotherDerive, Clone, Debug, ExtraDerive, serde :: Deserialize, serde :: Serialize)]
#[derive(
:: serde :: Deserialize, :: serde :: Serialize, AnotherDerive, Clone, Debug, ExtraDerive,
)]
pub struct Veggies {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub fruits: Vec<String>,
Expand Down
38 changes: 19 additions & 19 deletions cargo-typify/tests/outputs/no-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
#[doc = r" Error types."]
pub mod error {
#[doc = r" Error from a TryFrom or FromStr implementation."]
pub struct ConversionError(std::borrow::Cow<'static, str>);
impl std::error::Error for ConversionError {}
impl std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
std::fmt::Display::fmt(&self.0, f)
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
std::fmt::Debug::fmt(&self.0, f)
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
Expand All @@ -39,15 +39,15 @@ pub mod error {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(Clone, Debug, serde :: Deserialize, serde :: Serialize)]
pub struct Fruit(pub serde_json::Map<String, serde_json::Value>);
impl std::ops::Deref for Fruit {
type Target = serde_json::Map<String, serde_json::Value>;
fn deref(&self) -> &serde_json::Map<String, serde_json::Value> {
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
pub struct Fruit(pub ::serde_json::Map<String, ::serde_json::Value>);
impl ::std::ops::Deref for Fruit {
type Target = ::serde_json::Map<String, ::serde_json::Value>;
fn deref(&self) -> &::serde_json::Map<String, ::serde_json::Value> {
&self.0
}
}
impl From<Fruit> for serde_json::Map<String, serde_json::Value> {
impl From<Fruit> for ::serde_json::Map<String, ::serde_json::Value> {
fn from(value: Fruit) -> Self {
value.0
}
Expand All @@ -57,8 +57,8 @@ impl From<&Fruit> for Fruit {
value.clone()
}
}
impl From<serde_json::Map<String, serde_json::Value>> for Fruit {
fn from(value: serde_json::Map<String, serde_json::Value>) -> Self {
impl From<::serde_json::Map<String, ::serde_json::Value>> for Fruit {
fn from(value: ::serde_json::Map<String, ::serde_json::Value>) -> Self {
Self(value)
}
}
Expand Down Expand Up @@ -89,7 +89,7 @@ impl From<serde_json::Map<String, serde_json::Value>> for Fruit {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(Clone, Debug, serde :: Deserialize, serde :: Serialize)]
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
#[serde(untagged)]
pub enum FruitOrVeg {
Veg(Veggie),
Expand Down Expand Up @@ -134,7 +134,7 @@ impl From<Fruit> for FruitOrVeg {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(Clone, Debug, serde :: Deserialize, serde :: Serialize)]
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
pub struct Veggie {
#[doc = "Do I like this vegetable?"]
#[serde(rename = "veggieLike")]
Expand Down Expand Up @@ -175,7 +175,7 @@ impl From<&Veggie> for Veggie {
#[doc = "}"]
#[doc = r" ```"]
#[doc = r" </details>"]
#[derive(Clone, Debug, serde :: Deserialize, serde :: Serialize)]
#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)]
pub struct Veggies {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub fruits: Vec<String>,
Expand Down
4 changes: 2 additions & 2 deletions typify-impl/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ mod tests {
)*
/// ```
/// </details>
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
pub enum ResultX {
Ok(u32),
Err(String),
Expand Down Expand Up @@ -1519,7 +1519,7 @@ mod tests {
#[doc = "true"]
/// ```
/// </details>
#[derive(A, B, C, Clone, D, Debug, serde::Deserialize, serde::Serialize)]
#[derive(::serde::Deserialize, ::serde::Serialize, A, B, C, Clone, D, Debug)]
pub enum ResultX {
Ok(u32),
Err(String),
Expand Down
Loading

0 comments on commit 01f3e26

Please sign in to comment.