Use .is_some() and .is_none() instead of comparing against None.
Comparing against None requires a value to impl PartialEq, is_none() and
is_some() do not and are more idiomatic.
.transactions
.iter()
.position(|tx| tx.tx_id == tx_id + 1);
- debug_assert!(tx != None);
+ debug_assert!(tx.is_some());
if let Some(idx) = tx {
let _ = self.transactions.remove(idx);
}
fn free_tx(&mut self, tx_id: u64) {
let tx = self.transactions.iter().position(|tx| tx.id == tx_id + 1);
- debug_assert!(tx != None);
+ debug_assert!(tx.is_some());
if let Some(idx) = tx {
let _ = self.transactions.remove(idx);
}
fn free_tx(&mut self, tx_id: u64) {
let tx = self.transactions.iter().position(|tx| tx.id == tx_id + 1);
- debug_assert!(tx != None);
+ debug_assert!(tx.is_some());
if let Some(idx) = tx {
let _ = self.transactions.remove(idx);
}
.transactions
.iter()
.position(|tx| tx.id == tx_id + 1);
- debug_assert!(tx != None);
+ debug_assert!(tx.is_some());
if let Some(idx) = tx {
let _ = self.transactions.remove(idx);
}
}
}
- if have_ntlmssp && kticket == None {
+ if have_ntlmssp && kticket.is_none() {
SCLogDebug!("parsing expected NTLMSSP");
ntlmssp = parse_ntlmssp_blob(os);
}
},
_ => { None },
};
- if d == None {
+ if d.is_none() {
tx.set_event(SMBEvent::NegotiateMalformedDialects);
}
(true, d)
/* if we have a fid, store it so the response can pick it up */
let mut pipe_dcerpc = false;
- if rd.pipe != None {
+ if rd.pipe.is_some() {
let pipe = rd.pipe.unwrap();
state.ssn2vec_map.insert(SMBCommonHdr::from1(r, SMBHDR_TYPE_GUID),
pipe.fid.to_vec());
let (i, _padding_evasion) = cond(data_offset > ax+4+2*(wct as u16), |b| take(data_offset - (ax+4+2*(wct as u16)))(b))(i)?;
let (i, file_data) = rest(i)?;
let record = Smb1WriteRequestRecord {
- offset: if high_offset != None { ((high_offset.unwrap() as u64) << 32)|(offset as u64) } else { 0 },
+ offset: if high_offset.is_some() { ((high_offset.unwrap() as u64) << 32)|(offset as u64) } else { 0 },
len: (((data_len_high as u32) << 16) as u32)|(data_len_low as u32),
fid,
data: file_data,
let record = SmbRequestReadAndXRecord {
fid,
size: (((max_count_high as u64) << 16)|max_count_low as u64),
- offset: if high_offset != None { ((high_offset.unwrap() as u64) << 32)|(offset as u64) } else { 0 },
+ offset: if high_offset.is_some() { ((high_offset.unwrap() as u64) << 32)|(offset as u64) } else { 0 },
};
Ok((i, record))
}
fn free_tx(&mut self, tx_id: u64) {
let tx = self.transactions.iter().position(|tx| tx.id == tx_id + 1);
- debug_assert!(tx != None);
+ debug_assert!(tx.is_some());
if let Some(idx) = tx {
let _ = self.transactions.remove(idx);
}
fn free_tx(&mut self, tx_id: u64) {
let tx = self.transactions.iter().position(|tx| tx.id == tx_id + 1);
- debug_assert!(tx != None);
+ debug_assert!(tx.is_some());
if let Some(idx) = tx {
let _ = self.transactions.remove(idx);
}