misc: clippy fixes (#126)

This commit is contained in:
Bruce Mitchener 2019-07-01 08:26:15 +07:00 committed by Toby Lawrence
parent 668fc877a6
commit 90b0c6b347
3 changed files with 14 additions and 12 deletions

View File

@ -508,6 +508,12 @@ impl FieldSet {
pub fn len(&self) -> usize {
self.names.len()
}
/// Returns whether or not this `FieldSet` has fields.
#[inline]
pub fn is_empty(&self) -> bool {
self.names.is_empty()
}
}
impl<'a> IntoIterator for &'a FieldSet {
@ -531,7 +537,7 @@ impl fmt::Debug for FieldSet {
impl fmt::Display for FieldSet {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_set()
.entries(self.names.iter().map(|n| display(n)))
.entries(self.names.iter().map(display))
.finish()
}
}

View File

@ -1,10 +1,7 @@
//! Subscribers collect and record trace data.
use crate::{span, Event, Metadata};
use std::{
any::{Any, TypeId},
ptr,
};
use std::any::{Any, TypeId};
/// Trait representing the functions required to collect trace data.
///
@ -109,9 +106,10 @@ pub trait Subscriber: 'static {
/// [`enabled`]: #method.enabled
/// [`rebuild_interest_cache`]: ../callsite/fn.rebuild_interest_cache.html
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest {
match self.enabled(metadata) {
true => Interest::always(),
false => Interest::never(),
if self.enabled(metadata) {
Interest::always()
} else {
Interest::never()
}
}
@ -363,7 +361,7 @@ impl dyn Subscriber {
pub fn downcast_ref<T: Any>(&self) -> Option<&T> {
unsafe {
let raw = self.downcast_raw(TypeId::of::<T>())?;
if raw == ptr::null() {
if raw.is_null() {
None
} else {
Some(&*(raw as *const _))

View File

@ -57,9 +57,7 @@ impl EnvFilter {
/// Returns a new `EnvFilter` from the value of the given environment
/// variable, ignoring any invalid filter directives.
pub fn from_env<A: AsRef<str>>(env: A) -> Self {
env::var(env.as_ref())
.map(|ref var| Self::new(var))
.unwrap_or_default()
env::var(env.as_ref()).map(Self::new).unwrap_or_default()
}
/// Returns a new `EnvFilter` from the directives in the given string,