Project

General

Profile

Actions

Optimization #4497

closed

rust: clean up constructors of state, transaction structs

Added by Victor Julien over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Effort:
Difficulty:
Label:

Description

Older code uses a lot of:

impl SMBVerCmdStat {
    pub fn new() -> SMBVerCmdStat {
        return SMBVerCmdStat {
            ...

Newer code uses Self:
impl RdpTransaction {
    fn new(id: u64, item: RdpTransactionItem) -> Self {
        Self {
           ...

Or even the Default logic like in:
pub struct IKEState {
    tx_id: u64,
    pub transactions: Vec<IKETransaction>,

    pub ikev1_container: Ikev1Container,
    pub ikev2_container: Ikev2Container,
}

By switching to Default by default we can clean things up, and where Default isn't feasible the use of Self is preferred.

Actions

Also available in: Atom PDF