Skip to content

Add documenation for task::name() #19945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion src/libstd/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,40 @@ pub fn try_future<T,F>(f: F) -> Future<Result<T, Box<Any + Send>>>

/* Lifecycle functions */

/// Read the name of the current task.
/// Returns the name of the current task.
///
/// Returns `None` if the task has no name.
///
/// # Examples
///
/// With a name:
///
/// ```
/// use std::task;
///
/// fn main() {
/// let name = task::name();
/// let main = Some("<main>".to_string());
///
/// assert_eq!(main, name);
/// }
/// ```
///
/// Without a name:
///
/// ```
/// use std::task;
///
/// fn main() {
/// let anon = None;
///
/// spawn(move || {
/// let name = task::name();
///
/// assert_eq!(anon, name);
/// });
/// }
/// ```
#[stable]
pub fn name() -> Option<String> {
use rustrt::task::Task;
Expand Down