Add doctests for span macro

This commit is contained in:
Eliza Weisman 2018-09-30 13:02:50 -07:00
parent ef2edd1b95
commit 9008d14497
No known key found for this signature in database
GPG Key ID: F9C1A595C3814436

View File

@ -112,6 +112,32 @@ macro_rules! static_meta {
)
}
/// Constructs a new span.
///
/// # Examples
///
/// Creating a new span with no fields:
/// ```
/// # #[macro_use]
/// # extern crate tokio_trace;
/// # fn main() {
/// let span = span!("my span");
/// span.enter(|| {
/// // do work inside the span...
/// });
/// # }
/// ```
///
/// Creating a span with fields:
/// ```
/// # #[macro_use]
/// # extern crate tokio_trace;
/// # fn main() {
/// span!("my span", foo = 2, bar = "a string").enter(|| {
/// // do work inside the span...
/// });
/// # }
/// ```
#[macro_export]
macro_rules! span {
($name:expr) => { span!($name,) };