From f836f36012eb9eb292aec8d39d65ba08f4a244c8 Mon Sep 17 00:00:00 2001 From: Josiah Bull Date: Sat, 7 Dec 2024 09:39:20 +1300 Subject: [PATCH] chore: small formatting changes. --- Cargo.lock | 14 ++++---------- typify-impl/Cargo.toml | 1 + typify-impl/src/defaults.rs | 2 +- typify-impl/src/structs.rs | 6 ++---- typify-impl/src/type_entry.rs | 4 ++-- typify-impl/src/value.rs | 4 ++-- typify-test/Cargo.toml | 2 +- 7 files changed, 13 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 43a4c483..15bb7677 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -448,12 +448,6 @@ dependencies = [ "allocator-api2", ] -[[package]] -name = "hashbrown" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" - [[package]] name = "heck" version = "0.5.0" @@ -512,12 +506,12 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.7.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.15.2", + "hashbrown", ] [[package]] @@ -792,7 +786,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1541daf4e4ed43a0922b7969bdc2170178bcacc5dabf7e39bc508a9fa3953a7a" dependencies = [ - "hashbrown 0.14.3", + "hashbrown", "memchr", ] diff --git a/typify-impl/Cargo.toml b/typify-impl/Cargo.toml index f3971109..dad413cf 100644 --- a/typify-impl/Cargo.toml +++ b/typify-impl/Cargo.toml @@ -21,6 +21,7 @@ syn = { version = "2.0.90", features = ["full"] } thiserror = "2.0.3" unicode-ident = "1.0.14" + [dev-dependencies] env_logger = "0.10.2" expectorate = "1.1.0" diff --git a/typify-impl/src/defaults.rs b/typify-impl/src/defaults.rs index 9a1cbbba..94dc1b67 100644 --- a/typify-impl/src/defaults.rs +++ b/typify-impl/src/defaults.rs @@ -620,7 +620,7 @@ fn all_props<'a>( // TODO Rather than an option, this should probably be something // that lets us say "explicit name" or "type to validate against" - TypeEntryDetails::Map(value_id, _) => return vec![(None, value_id, false)], + TypeEntryDetails::Map(_, value_id) => return vec![(None, value_id, false)], _ => unreachable!(), }; diff --git a/typify-impl/src/structs.rs b/typify-impl/src/structs.rs index 7e81919d..a3e68f37 100644 --- a/typify-impl/src/structs.rs +++ b/typify-impl/src/structs.rs @@ -460,7 +460,7 @@ fn has_default( // No default specified. (Some(TypeEntryDetails::Option(_)), None) => StructPropertyState::Optional, (Some(TypeEntryDetails::Vec(_)), None) => StructPropertyState::Optional, - (Some(TypeEntryDetails::Map { .. }), None) => StructPropertyState::Optional, + (Some(TypeEntryDetails::Map(..)), None) => StructPropertyState::Optional, (Some(TypeEntryDetails::Unit), None) => StructPropertyState::Optional, (_, None) => StructPropertyState::Required, @@ -473,9 +473,7 @@ fn has_default( StructPropertyState::Optional } // Default specified is the same as the implicit default: {} - (Some(TypeEntryDetails::Map { .. }), Some(serde_json::Value::Object(m))) - if m.is_empty() => - { + (Some(TypeEntryDetails::Map(..)), Some(serde_json::Value::Object(m))) if m.is_empty() => { StructPropertyState::Optional } // Default specified is the same as the implicit default: false diff --git a/typify-impl/src/type_entry.rs b/typify-impl/src/type_entry.rs index 16c35413..cdb9585b 100644 --- a/typify-impl/src/type_entry.rs +++ b/typify-impl/src/type_entry.rs @@ -595,7 +595,7 @@ impl TypeEntry { TypeEntryDetails::Unit | TypeEntryDetails::Option(_) | TypeEntryDetails::Vec(_) - | TypeEntryDetails::Map { .. } + | TypeEntryDetails::Map(_, _) | TypeEntryDetails::Set(_) => { matches!(impl_name, TypeSpaceImpl::Default) } @@ -1750,7 +1750,7 @@ impl TypeEntry { | TypeEntryDetails::Struct(_) | TypeEntryDetails::Newtype(_) | TypeEntryDetails::Vec(_) - | TypeEntryDetails::Map { .. } + | TypeEntryDetails::Map(..) | TypeEntryDetails::Set(_) | TypeEntryDetails::Box(_) | TypeEntryDetails::Native(_) diff --git a/typify-impl/src/value.rs b/typify-impl/src/value.rs index e4e5c68c..58012f81 100644 --- a/typify-impl/src/value.rs +++ b/typify-impl/src/value.rs @@ -95,7 +95,7 @@ impl TypeEntry { .collect::>>()?; quote! { vec![#(#values),*] } } - TypeEntryDetails::Map(key_id, value_id, ..) => { + TypeEntryDetails::Map(key_id, value_id) => { let obj = value.as_object()?; let key_ty = type_space.id_to_entry.get(key_id).unwrap(); let value_ty = type_space.id_to_entry.get(value_id).unwrap(); @@ -424,7 +424,7 @@ fn value_for_struct_props( match &type_entry.details { TypeEntryDetails::Struct(_) | TypeEntryDetails::Option(_) - | TypeEntryDetails::Map { .. } => (), + | TypeEntryDetails::Map(..) => (), _ => unreachable!(), } diff --git a/typify-test/Cargo.toml b/typify-test/Cargo.toml index d8626ab1..2b4d7f50 100644 --- a/typify-test/Cargo.toml +++ b/typify-test/Cargo.toml @@ -14,4 +14,4 @@ prettyplease = "0.2.25" schemars = "0.8.21" serde = "1.0.215" syn = "2.0.90" -typify = { path = "../typify"} +typify = { path = "../typify" }