cleanup some awkward Option call chains

This commit is contained in:
Scott Lamb 2021-05-06 09:47:07 -07:00
parent 33e8359b01
commit 80ec7ab1d0
3 changed files with 5 additions and 5 deletions

View File

@ -76,7 +76,7 @@ pub fn run(args: &Args) -> Result<i32, Error> {
let (sid, _) = l.make_session( let (sid, _) = l.make_session(
creation, creation,
uid, uid,
args.domain.as_ref().map(|d| d.as_bytes().to_owned()), args.domain.clone().map(String::into_bytes),
flags, flags,
permissions, permissions,
)?; )?;

View File

@ -260,7 +260,7 @@ pub async fn run(args: &Args) -> Result<i32, Error> {
let rotate_offset_sec = streamer::ROTATE_INTERVAL_SEC * i as i64 / streams as i64; let rotate_offset_sec = streamer::ROTATE_INTERVAL_SEC * i as i64 / streams as i64;
let syncer = syncers.get(&sample_file_dir_id).unwrap(); let syncer = syncers.get(&sample_file_dir_id).unwrap();
let object_detector = match stream.type_ { let object_detector = match stream.type_ {
db::StreamType::SUB => object_detector.as_ref().map(|a| Arc::clone(a)), db::StreamType::SUB => object_detector.clone(),
_ => None, _ => None,
}; };
let mut streamer = streamer::Streamer::new( let mut streamer = streamer::Streamer::new(

View File

@ -1062,9 +1062,9 @@ impl Service {
.strftime("%FT%T") .strftime("%FT%T")
.map(|f| f.to_string()) .map(|f| f.to_string())
.unwrap_or_else(|e| e.to_string()), .unwrap_or_else(|e| e.to_string()),
host.as_ref().map(|h| &*h), host.as_deref(),
&authreq.addr, &authreq.addr,
agent.as_ref().map(|a| &*a), agent.as_deref(),
self.is_secure(req) self.is_secure(req)
), ),
)) ))
@ -1465,7 +1465,7 @@ mod tests {
/// Produces a `Cookie` header value. /// Produces a `Cookie` header value.
pub fn header(&self) -> String { pub fn header(&self) -> String {
self.0.as_ref().map(|s| s.as_str()).unwrap_or("").to_owned() self.0.clone().unwrap()
} }
} }