refactor(exec): fix unused warning when runtime feature is disabled

This commit is contained in:
Sean McArthur
2018-10-16 15:53:55 -07:00
parent c5e807715a
commit 8bfe3c220c

View File

@@ -1,4 +1,3 @@
use std::error::Error as StdError;
use std::fmt; use std::fmt;
use std::sync::Arc; use std::sync::Arc;
@@ -36,7 +35,29 @@ impl Exec {
Exec::Default => { Exec::Default => {
#[cfg(feature = "runtime")] #[cfg(feature = "runtime")]
{ {
use std::error::Error as StdError;
use ::tokio_executor::Executor; use ::tokio_executor::Executor;
struct TokioSpawnError;
impl fmt::Debug for TokioSpawnError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt("tokio::spawn failed (is a tokio runtime running this future?)", f)
}
}
impl fmt::Display for TokioSpawnError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt("tokio::spawn failed (is a tokio runtime running this future?)", f)
}
}
impl StdError for TokioSpawnError {
fn description(&self) -> &str {
"tokio::spawn failed"
}
}
::tokio_executor::DefaultExecutor::current() ::tokio_executor::DefaultExecutor::current()
.spawn(Box::new(fut)) .spawn(Box::new(fut))
.map_err(|err| { .map_err(|err| {
@@ -125,23 +146,3 @@ where
// ===== StdError impls ===== // ===== StdError impls =====
struct TokioSpawnError;
impl fmt::Debug for TokioSpawnError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt("tokio::spawn failed (is a tokio runtime running this future?)", f)
}
}
impl fmt::Display for TokioSpawnError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt("tokio::spawn failed (is a tokio runtime running this future?)", f)
}
}
impl StdError for TokioSpawnError {
fn description(&self) -> &str {
"tokio::spawn failed"
}
}