mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-06 07:17:27 +00:00
chore: use Self where possible
This commit is contained in:
parent
f431508418
commit
486abbd9f7
3 changed files with 10 additions and 10 deletions
|
|
@ -231,33 +231,33 @@ impl TimeoutSettings {
|
|||
|
||||
/// Get the number of retries if there are timeout settings else fall back
|
||||
/// to the default
|
||||
pub const fn get_retries_or_default(timeout_settings: &Option<TimeoutSettings>) -> usize {
|
||||
pub const fn get_retries_or_default(timeout_settings: &Option<Self>) -> usize {
|
||||
if let Some(timeout_settings) = timeout_settings {
|
||||
timeout_settings.get_retries()
|
||||
} else {
|
||||
TimeoutSettings::const_default().get_retries()
|
||||
Self::const_default().get_retries()
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the read and write durations if there are timeout settings else fall
|
||||
/// back to the defaults
|
||||
pub const fn get_read_and_write_or_defaults(
|
||||
timeout_settings: &Option<TimeoutSettings>,
|
||||
timeout_settings: &Option<Self>,
|
||||
) -> (Option<Duration>, Option<Duration>) {
|
||||
if let Some(timeout_settings) = timeout_settings {
|
||||
(timeout_settings.get_read(), timeout_settings.get_write())
|
||||
} else {
|
||||
let default = TimeoutSettings::const_default();
|
||||
let default = Self::const_default();
|
||||
(default.get_read(), default.get_write())
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the connect duration given timeout settings or get the default.
|
||||
pub const fn get_connect_or_default(timeout_settings: &Option<TimeoutSettings>) -> Option<Duration> {
|
||||
pub const fn get_connect_or_default(timeout_settings: &Option<Self>) -> Option<Duration> {
|
||||
if let Some(timeout_settings) = timeout_settings {
|
||||
timeout_settings.get_connect()
|
||||
} else {
|
||||
TimeoutSettings::const_default().get_connect()
|
||||
Self::const_default().get_connect()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ pub struct ServerInfo {
|
|||
|
||||
impl ServerInfo {
|
||||
pub fn parse<B: ByteOrder>(buffer: &mut Buffer<B>) -> GDResult<Self> {
|
||||
Ok(ServerInfo {
|
||||
Ok(Self {
|
||||
server_id: buffer.read()?,
|
||||
ip: buffer.read_string::<Unreal2StringDecoder>(None)?,
|
||||
game_port: buffer.read()?,
|
||||
|
|
@ -118,7 +118,7 @@ impl Players {
|
|||
/// Pre-allocate the vectors inside the players struct based on the provided
|
||||
/// capacity.
|
||||
pub fn with_capacity(capacity: usize) -> Self {
|
||||
Players {
|
||||
Self {
|
||||
players: Vec::with_capacity(capacity),
|
||||
// Allocate half as many bots as we don't expect there to be as many
|
||||
bots: Vec::with_capacity(capacity / 2),
|
||||
|
|
@ -234,7 +234,7 @@ impl GatheringSettings {
|
|||
}
|
||||
|
||||
impl Default for GatheringSettings {
|
||||
fn default() -> Self { GatheringSettings::default() }
|
||||
fn default() -> Self { Self::default() }
|
||||
}
|
||||
|
||||
impl From<ExtraRequestSettings> for GatheringSettings {
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ impl GatheringSettings {
|
|||
}
|
||||
|
||||
impl Default for GatheringSettings {
|
||||
fn default() -> Self { GatheringSettings::default() }
|
||||
fn default() -> Self { Self::default() }
|
||||
}
|
||||
|
||||
impl From<ExtraRequestSettings> for GatheringSettings {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue