Skip to content

Commit

Permalink
accept &str instead of Into<Cow<'static, str>>
Browse files Browse the repository at this point in the history
  • Loading branch information
jbr committed Jun 19, 2021
1 parent 29caf61 commit 2a821b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tokio/src/task/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ cfg_rt! {

cfg_trace! {
#[cfg_attr(tokio_track_caller, track_caller)]
pub fn spawn_named<T>(name: impl Into<std::borrow::Cow<'static, str>>, task: T) -> JoinHandle<T::Output>
pub fn spawn_named<T>(name: &str, task: T) -> JoinHandle<T::Output>
where
T: Future + Send + 'static,
T::Output: Send + 'static,
{
let spawn_handle = runtime::context::spawn_handle()
.expect(CONTEXT_MISSING_ERROR);
let task = crate::util::trace::task(task, "task", Some(name.into()));
let task = crate::util::trace::task(task, "task", Some(name));
spawn_handle.spawn(task)
}
}
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/util/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cfg_trace! {

#[inline]
#[cfg_attr(tokio_track_caller, track_caller)]
pub(crate) fn task<F>(task: F, kind: &'static str, name: Option<std::borrow::Cow<'static, str>>) -> Instrumented<F> {
pub(crate) fn task<F>(task: F, kind: &'static str, name: Option<&str>) -> Instrumented<F> {
use tracing::instrument::Instrument;
#[cfg(tokio_track_caller)]
let location = std::panic::Location::caller();
Expand All @@ -31,7 +31,7 @@ cfg_trace! {
cfg_not_trace! {
cfg_rt! {
#[inline]
pub(crate) fn task<F>(task: F, _: &'static str, _name: Option<std::borrow::Cow<'static, str>>) -> F {
pub(crate) fn task<F>(task: F, _: &'static str, _name: Option<&str>) -> F {
// nop
task
}
Expand Down

0 comments on commit 2a821b8

Please sign in to comment.