Function try_id
pub fn try_id() -> Option<Id>
Available on crate feature
rt only.Returns the Id of the currently running task, or None if called outside of a task.
This function is similar to task::id(), except that it returns None rather than panicking if called outside of a task context.
MIT License
Copyright © Tokio Contributors
https://docs.rs/tokio/1.53.1/tokio/task/fn.try_id.html