Skip to content
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

Allow owned values and fat pointers in Span::record #2212

Merged
merged 2 commits into from Jul 13, 2022

Commits on Jul 13, 2022

  1. Allow owned values and fat pointers in Span::record

    Previously, using `record("x", "y")` would give an error:
    ```
    error[E0277]: the size for values of type `str` cannot be known at compilation time
        --> src/main.rs:3:22
         |
    243  |                 span.record("x", "y");
         |                      ^^^^^^ doesn't have a size known at compile-time
         |
         = help: the trait `Sized` is not implemented for `str`
    note: required by a bound in `Span::record`
        --> /home/jnelson/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/tracing-0.1.32/src/span.rs:1184:30
         |
    1184 |     pub fn record<Q: ?Sized, V>(&self, field: &Q, value: &V) -> &Self
         |                              ^ required by this bound in `Span::record`
    ```
    
    Now it works fine, as tested by the doc-example.
    
    This doesn't break any existing code, because there's a generic `impl<T: Value> Value for &T`: https://docs.rs/tracing/0.1.35/tracing/trait.Value.html#impl-Value-for-%26%27a%20T
    jyn514 committed Jul 13, 2022
    Configuration menu
    Copy the full SHA
    f7868be View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9b4dd8c View commit details
    Browse the repository at this point in the history