Skip to content

Commit ae0e83a

Browse files
authored
Merge pull request #334 from fox0/default-talk
talk: #[derive(Default)]
2 parents fee80bb + d6c1195 commit ae0e83a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

users/talk.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,15 @@ const MAX_USER_INPUT_LENGTH: usize = 128;
6868
/// The version number for the talk protocol.
6969
const TALK_VERSION: u8 = 1;
7070

71-
#[derive(Debug, Copy, Clone, PartialEq)]
71+
#[derive(Debug, Default, Copy, Clone, PartialEq)]
7272
#[binrw]
7373
#[brw(repr(u8))]
7474
/// Represents the types of messages exchanged in the communication.
7575
enum MessageType {
7676
/// Leave invitation with server.
7777
LeaveInvite,
7878
/// Check for invitation by callee.
79+
#[default]
7980
LookUp,
8081
/// Delete invitation by caller.
8182
Delete,
@@ -295,7 +296,7 @@ impl Default for CtlMsg {
295296
fn default() -> Self {
296297
CtlMsg {
297298
vers: 1,
298-
r#type: MessageType::LookUp as u8,
299+
r#type: MessageType::default() as u8,
299300
answer: Answer::Success as u8,
300301
pad: 0,
301302
id_num: 0,
@@ -360,14 +361,11 @@ impl Default for CtlRes {
360361
fn default() -> Self {
361362
CtlRes {
362363
vers: 0,
363-
r#type: MessageType::LookUp,
364+
r#type: MessageType::default(),
364365
answer: Answer::Failed,
365366
pad: 0,
366367
id_num: 0,
367-
addr: Osockaddr {
368-
sa_family: 0,
369-
sa_data: [0; 14],
370-
},
368+
addr: Osockaddr::default(),
371369
}
372370
}
373371
}

0 commit comments

Comments
 (0)