Function tokio::task::try_id

source ·
pub fn try_id() -> Option<Id>
Available on crate feature rt and tokio_unstable only.
Expand description

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.

Note: This is an unstable API. The public API of this type may break in 1.x releases. See the documentation on unstable features for details.