Просмотр исходного кода

Merge pull request #2 from parazyd/net-var-clash

net/messages: Rename command variable so it doesn't clash with struct
∞ − 0 − a + a + 0 = ∞ 5 лет назад
Родитель
Сommit
c6bd2d49de
1 измененных файлов с 5 добавлено и 5 удалено
  1. 5 5
      src/net/messages.rs

+ 5 - 5
src/net/messages.rs

@@ -180,12 +180,12 @@ pub async fn read_packet<R: AsyncRead + Unpin>(stream: &mut R) -> Result<Packet>
 
 
     // The type of the message
     // The type of the message
     let command_len = VarInt::decode_async(stream).await?.0 as usize;
     let command_len = VarInt::decode_async(stream).await?.0 as usize;
-    let mut command = vec![0u8; command_len];
+    let mut cmd = vec![0u8; command_len];
     if command_len > 0 {
     if command_len > 0 {
-        stream.read_exact(&mut command).await?;
+        stream.read_exact(&mut cmd).await?;
     }
     }
-    let command = String::from_utf8(command)?;
-    debug!(target: "net", "read command: {}", command);
+    let cmd = String::from_utf8(cmd)?;
+    debug!(target: "net", "read command: {}", cmd);
 
 
     let payload_len = VarInt::decode_async(stream).await?.0 as usize;
     let payload_len = VarInt::decode_async(stream).await?.0 as usize;
 
 
@@ -197,7 +197,7 @@ pub async fn read_packet<R: AsyncRead + Unpin>(stream: &mut R) -> Result<Packet>
     debug!(target: "net", "read payload {} bytes", payload_len);
     debug!(target: "net", "read payload {} bytes", payload_len);
 
 
     Ok(Packet {
     Ok(Packet {
-        command: command,
+        command: cmd,
         payload,
         payload,
     })
     })
 }
 }