Skip to content

Commit

Permalink
refactor: remove the unnecessary Option in the z_liveliness example…
Browse files Browse the repository at this point in the history
… for clarity (eclipse-zenoh#1316)
  • Loading branch information
YuanYuYuan authored and gmartin82 committed Aug 21, 2024
1 parent db0aaeb commit c0a370b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions examples/examples/z_liveliness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ async fn main() {
let session = zenoh::open(config).await.unwrap();

println!("Declaring LivelinessToken on '{}'...", &key_expr);
let mut token = Some(session.liveliness().declare_token(&key_expr).await.unwrap());
let token = session.liveliness().declare_token(&key_expr).await.unwrap();

println!("Press CTRL-C to undeclare LivelinessToken and quit...");
std::thread::park();

// LivelinessTokens are automatically closed when dropped
// Use the code below to manually undeclare it if needed
if let Some(token) = token.take() {
println!("Undeclaring LivelinessToken...");
token.undeclare().await.unwrap();
};
token.undeclare().await.unwrap();
}

#[derive(clap::Parser, Clone, PartialEq, Eq, Hash, Debug)]
Expand Down

0 comments on commit c0a370b

Please sign in to comment.