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 <paul@zoo.dev>
This commit is contained in:
Paul Tagliamonte
2024-07-18 15:20:50 -04:00
committed by GitHub
parent 01076c3aed
commit a782f26ec2

View File

@ -160,19 +160,13 @@ impl EngineConnection {
Ok(()) Ok(())
} }
#[allow(clippy::field_reassign_with_default)]
pub async fn new(ws: reqwest::Upgraded) -> Result<EngineConnection> { pub async fn new(ws: reqwest::Upgraded) -> Result<EngineConnection> {
// allowing the field_reassign_with_default lint here because the let wsconfig = tokio_tungstenite::tungstenite::protocol::WebSocketConfig {
// defaults for this object don't match the type defaults. We want // 4294967296 bytes, which is around 4.2 GB.
// to inherent the default config max_message_size: Some(0x100000000),
// max_frame_size: Some(0x100000000),
// See the `impl Default for WebSocketConfig` in ..Default::default()
// `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 ws_stream = tokio_tungstenite::WebSocketStream::from_raw_socket( let ws_stream = tokio_tungstenite::WebSocketStream::from_raw_socket(
ws, ws,