Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed Jul 31, 2020
1 parent 43aea71 commit babd65e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
34 changes: 25 additions & 9 deletions src/trace/allow_origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ use std::option;
use std::slice;

/// Specify origins that are allowed to see values via the Resource Timing API.
///
/// # Examples
///
/// ```
/// # fn main() -> http_types::Result<()> {
/// #
/// use http_types::Response;
/// use http_types::trace::{AllowOrigin, Origin};
///
/// let mut origins = AllowOrigin::new();
/// origins.push(Origin::Wildcard);
///
/// let mut res = Response::new(200);
/// origins.apply(&mut res);
///
/// let origins = AllowOrigin::from_headers(res)?.unwrap();
/// let origin = origins.iter().next().unwrap();
/// assert_eq!(origin, &Origin::Wildcard);
/// #
/// # Ok(()) }
/// ```
#[derive(Clone, Eq, PartialEq)]
pub struct AllowOrigin {
origins: Vec<Origin>,
Expand All @@ -60,7 +81,7 @@ impl AllowOrigin {

let mut origins = vec![];
for header in headers {
for origin in header.as_str().split(",") {
for origin in header.as_str().split(',') {
match origin.trim_start() {
"*" => origins.push(Origin::Wildcard),
r#""null""# => continue,
Expand Down Expand Up @@ -105,13 +126,6 @@ impl AllowOrigin {
unsafe { HeaderValue::from_bytes_unchecked(output.into()) }
}

/// An iterator visiting all server timings.
pub fn into_iter(self) -> IntoIter {
IntoIter {
inner: self.origins.into_iter(),
}
}

/// An iterator visiting all server timings.
pub fn iter(&self) -> Iter<'_> {
Iter {
Expand All @@ -133,7 +147,9 @@ impl IntoIterator for AllowOrigin {

#[inline]
fn into_iter(self) -> Self::IntoIter {
self.into_iter()
IntoIter {
inner: self.origins.into_iter(),
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/trace/server_timing/metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Metric {

/// The timing description.
pub fn description(&self) -> Option<&str> {
self.desc.as_ref().map(|s| s.as_str())
self.desc.as_deref()
}
}

Expand Down
11 changes: 3 additions & 8 deletions src/trace/server_timing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@ impl ServerTiming {
self.timings.push(entry);
}

/// An iterator visiting all server timings.
pub fn into_iter(self) -> IntoIter {
IntoIter {
inner: self.timings.into_iter(),
}
}

/// An iterator visiting all server timings.
pub fn iter(&self) -> Iter<'_> {
Iter {
Expand All @@ -145,7 +138,9 @@ impl IntoIterator for ServerTiming {

#[inline]
fn into_iter(self) -> Self::IntoIter {
self.into_iter()
IntoIter {
inner: self.timings.into_iter(),
}
}
}

Expand Down

0 comments on commit babd65e

Please sign in to comment.