From 7300d0c9712eb13194b7ff26af9a209440806d0d Mon Sep 17 00:00:00 2001 From: Shane Madden Date: Wed, 14 Aug 2024 17:54:26 -0600 Subject: [PATCH] Stop using __Nonexhaustive for market type conversion (#527) --- CHANGELOG.md | 4 ++++ src/constants/types.rs | 36 +++++++++++++++--------------------- src/lib.rs | 4 ++++ 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4382c13..a2a66692 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Unreleased ========== +### Bugfixes: + +- Update for new string enum implementation's implementation in wasm-bindgen 0.2.93 + ### Misc: - Move crate constant `ROOM_AREA` to extra constants module and make public diff --git a/src/constants/types.rs b/src/constants/types.rs index 934a5e7b..394ff2f4 100644 --- a/src/constants/types.rs +++ b/src/constants/types.rs @@ -674,7 +674,7 @@ impl wasm_bindgen::convert::FromWasmAbi for MarketResourceType { // try with IntershardResourceType match IntershardResourceType::from_js_value(&s) { Some(r) => Self::IntershardResource(r), - None => Self::Resource(ResourceType::__Nonexhaustive), + None => unreachable!("should have come from IntoWasmAbi"), } } } @@ -834,7 +834,7 @@ mod test { #[test] fn resources_rust_to_serde_json_from_serde_json_roundtrip() { for resource in enum_iterator::all::() { - if resource != ResourceType::__Nonexhaustive { + if resource != ResourceType::__Invalid { let serialized = serde_json::to_string(&resource).unwrap(); let parsed: ResourceType = serde_json::from_str(&serialized).unwrap(); assert_eq!(resource, parsed); @@ -845,7 +845,7 @@ mod test { #[test] fn resources_rust_to_display_from_str_roundtrip() { for resource in enum_iterator::all::() { - if resource != ResourceType::__Nonexhaustive { + if resource != ResourceType::__Invalid { let string = format!("{}", resource); let parsed = ResourceType::from_str(&string).unwrap(); assert_eq!(resource, parsed); @@ -857,7 +857,7 @@ mod test { fn resources_rust_vec_to_serde_json_from_serde_json_roundtrip() { let mut resources = vec![]; for resource in enum_iterator::all::() { - if resource != ResourceType::__Nonexhaustive { + if resource != ResourceType::__Invalid { resources.push(resource); } } @@ -870,7 +870,7 @@ mod test { fn resources_rust_vec_to_serde_json_from_serde_json_roundtrip_via_values() { let mut resources = vec![]; for resource in enum_iterator::all::() { - if resource != ResourceType::__Nonexhaustive { + if resource != ResourceType::__Invalid { resources.push(resource); } } @@ -887,7 +887,7 @@ mod test { #[test] fn intershard_resources_rust_to_serde_json_from_serde_json_roundtrip() { for resource in enum_iterator::all::() { - if resource != IntershardResourceType::__Nonexhaustive { + if resource != IntershardResourceType::__Invalid { let serialized = serde_json::to_string(&resource).unwrap(); let parsed: IntershardResourceType = serde_json::from_str(&serialized).unwrap(); assert_eq!(resource, parsed); @@ -898,7 +898,7 @@ mod test { #[test] fn intershard_resources_rust_to_display_from_str_roundtrip() { for resource in enum_iterator::all::() { - if resource != IntershardResourceType::__Nonexhaustive { + if resource != IntershardResourceType::__Invalid { let string = format!("{}", resource); let parsed = IntershardResourceType::from_str(&string).unwrap(); assert_eq!(resource, parsed); @@ -910,7 +910,7 @@ mod test { fn intershard_resources_rust_vec_to_serde_json_from_serde_json_roundtrip() { let mut resources = vec![]; for resource in enum_iterator::all::() { - if resource != IntershardResourceType::__Nonexhaustive { + if resource != IntershardResourceType::__Invalid { resources.push(resource); } } @@ -924,7 +924,7 @@ mod test { fn intershard_resources_rust_vec_to_serde_json_from_serde_json_roundtrip_via_values() { let mut resources = vec![]; for resource in enum_iterator::all::() { - if resource != IntershardResourceType::__Nonexhaustive { + if resource != IntershardResourceType::__Invalid { resources.push(resource); } } @@ -941,11 +941,9 @@ mod test { #[test] fn market_resources_rust_to_serde_json_from_serde_json_roundtrip() { for resource in enum_iterator::all::() { - if resource != MarketResourceType::Resource(ResourceType::__Nonexhaustive) + if resource != MarketResourceType::Resource(ResourceType::__Invalid) && resource - != MarketResourceType::IntershardResource( - IntershardResourceType::__Nonexhaustive, - ) + != MarketResourceType::IntershardResource(IntershardResourceType::__Invalid) { let serialized = serde_json::to_string(&resource).unwrap(); let parsed: MarketResourceType = serde_json::from_str(&serialized).unwrap(); @@ -958,11 +956,9 @@ mod test { fn market_resources_rust_vec_to_serde_json_from_serde_json_roundtrip() { let mut resources = vec![]; for resource in enum_iterator::all::() { - if resource != MarketResourceType::Resource(ResourceType::__Nonexhaustive) + if resource != MarketResourceType::Resource(ResourceType::__Invalid) && resource - != MarketResourceType::IntershardResource( - IntershardResourceType::__Nonexhaustive, - ) + != MarketResourceType::IntershardResource(IntershardResourceType::__Invalid) { resources.push(resource); } @@ -977,11 +973,9 @@ mod test { fn market_resources_rust_vec_to_serde_json_from_serde_json_roundtrip_via_values() { let mut resources = vec![]; for resource in enum_iterator::all::() { - if resource != MarketResourceType::Resource(ResourceType::__Nonexhaustive) + if resource != MarketResourceType::Resource(ResourceType::__Invalid) && resource - != MarketResourceType::IntershardResource( - IntershardResourceType::__Nonexhaustive, - ) + != MarketResourceType::IntershardResource(IntershardResourceType::__Invalid) { resources.push(resource); } diff --git a/src/lib.rs b/src/lib.rs index 6117ad0f..0b87246b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,6 +94,10 @@ // #![warn(clippy::missing_const_for_fn)] +// disable deprecation warnings - TODO need to figure out how to get wasm_bindgen's new thread_local +// attribute working +#![allow(deprecated)] + pub mod console; pub mod constants; pub mod enums;