mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-06 07:17:27 +00:00
perf: use of ok_or followed by a function call
This commit is contained in:
parent
e1bffd2045
commit
9c3e6cb51f
3 changed files with 3 additions and 3 deletions
|
|
@ -90,7 +90,7 @@ pub fn query_with_timeout(
|
|||
let packets = client.get_server_packets()?;
|
||||
let data = packets
|
||||
.get(0)
|
||||
.ok_or(PacketBad.context("First packet missing"))?;
|
||||
.ok_or_else(|| PacketBad.context("First packet missing"))?;
|
||||
|
||||
let (mut server_vars, remaining_data) = data_to_map(data)?;
|
||||
let players = parse_players_and_teams(&remaining_data)?;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::collections::HashMap;
|
|||
pub fn has_password(server_vars: &mut HashMap<String, String>) -> GDResult<bool> {
|
||||
let password_value = server_vars
|
||||
.remove("password")
|
||||
.ok_or(GDErrorKind::PacketBad.context("Missing password (exists) field"))?
|
||||
.ok_or_else(|| GDErrorKind::PacketBad.context("Missing password (exists) field"))?
|
||||
.to_lowercase();
|
||||
|
||||
if let Ok(has) = password_value.parse::<bool>() {
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ impl StringDecoder for Unreal2StringDecoder {
|
|||
let mut ucs2 = false;
|
||||
let mut length: usize = (*data
|
||||
.first()
|
||||
.ok_or(PacketBad.context("Tried to decode string without length"))?)
|
||||
.ok_or_else(|| PacketBad.context("Tried to decode string without length"))?)
|
||||
.into();
|
||||
|
||||
let mut start = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue