From a782f26ec2d6c8f93b99d08094dcfa81cddbb623 Mon Sep 17 00:00:00 2001 From: Paul Tagliamonte Date: Thu, 18 Jul 2024 15:20:50 -0400 Subject: [PATCH] Use ..Default::default() with a struct constructor (#3068) As @jtran pointed out - I had misunderstood the behavior of Default::default(), we can instead rely on this syntax to do the same thing. This won't use each field's default value -- rather, it'll use the type's Default, and override each field. Neat! Signed-off-by: Paul Tagliamonte --- src/wasm-lib/kcl/src/engine/conn.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/wasm-lib/kcl/src/engine/conn.rs b/src/wasm-lib/kcl/src/engine/conn.rs index aeaba96a5..76fe3b933 100644 --- a/src/wasm-lib/kcl/src/engine/conn.rs +++ b/src/wasm-lib/kcl/src/engine/conn.rs @@ -160,19 +160,13 @@ impl EngineConnection { Ok(()) } - #[allow(clippy::field_reassign_with_default)] pub async fn new(ws: reqwest::Upgraded) -> Result { - // allowing the field_reassign_with_default lint here because the - // defaults for this object don't match the type defaults. We want - // to inherent the default config - // - // See the `impl Default for WebSocketConfig` in - // `tungstenite/protocol/mod.rs` - - let mut wsconfig = tokio_tungstenite::tungstenite::protocol::WebSocketConfig::default(); - // 4294967296 bytes, which is around 4.2 GB. - wsconfig.max_message_size = Some(0x100000000); - wsconfig.max_frame_size = Some(0x100000000); + let wsconfig = tokio_tungstenite::tungstenite::protocol::WebSocketConfig { + // 4294967296 bytes, which is around 4.2 GB. + max_message_size: Some(0x100000000), + max_frame_size: Some(0x100000000), + ..Default::default() + }; let ws_stream = tokio_tungstenite::WebSocketStream::from_raw_socket( ws,