Rocket

A web framework for Rust. https://rocket.rs (mirror)
git clone git://git.thc420.xyz/Rocket
Log | Files | Refs | README

commit 90e37beb2f9ad704944df2f9b83547d6a3244df3
parent 42f8af411ed0d07c4acb15179b3f37d3681e9280
Author: Jeb Rosen <jeb@jebrosen.com>
Date:   Wed, 12 Jun 2019 18:33:40 -0700

Migrate http to Rust 2018.

Diffstat:
Mcore/http/Cargo.toml | 1+
Mcore/http/src/accept.rs | 14+++++++-------
Mcore/http/src/content_type.rs | 10+++++-----
Mcore/http/src/cookies.rs | 26+++++++++++++-------------
Mcore/http/src/ext.rs | 8++++----
Mcore/http/src/header.rs | 17+++++++++--------
Mcore/http/src/hyper.rs | 36+++++++++++++++++-------------------
Mcore/http/src/lib.rs | 31+++++++++++++------------------
Mcore/http/src/media_type.rs | 21+++++++++++----------
Mcore/http/src/method.rs | 4++--
Mcore/http/src/parse/accept.rs | 14+++++++-------
Mcore/http/src/parse/checkers.rs | 2+-
Mcore/http/src/parse/indexed.rs | 20++++++++++----------
Mcore/http/src/parse/media_type.rs | 14+++++++-------
Mcore/http/src/parse/uri/error.rs | 16++++++++--------
Mcore/http/src/parse/uri/mod.rs | 14+++++++-------
Mcore/http/src/parse/uri/parser.rs | 10+++++-----
Mcore/http/src/parse/uri/tests.rs | 6+++---
Mcore/http/src/raw_str.rs | 26+++++++++++++-------------
Mcore/http/src/route.rs | 17+++++++++--------
Mcore/http/src/status.rs | 2+-
Mcore/http/src/tls.rs | 7++-----
Mcore/http/src/uncased.rs | 38+++++++++++++++++++-------------------
Mcore/http/src/uri/absolute.rs | 16++++++++--------
Mcore/http/src/uri/authority.rs | 16++++++++--------
Mcore/http/src/uri/encoding.rs | 8++++----
Mcore/http/src/uri/formatter.rs | 28++++++++++++++--------------
Mcore/http/src/uri/from_uri_param.rs | 24++++++++++++------------
Mcore/http/src/uri/mod.rs | 14+++++++-------
Mcore/http/src/uri/origin.rs | 28++++++++++++++--------------
Mcore/http/src/uri/segments.rs | 4++--
Mcore/http/src/uri/uri.rs | 48++++++++++++++++++++++++------------------------
Mcore/http/src/uri/uri_display.rs | 62+++++++++++++++++++++++++++++++-------------------------------
33 files changed, 298 insertions(+), 304 deletions(-)

diff --git a/core/http/Cargo.toml b/core/http/Cargo.toml @@ -12,6 +12,7 @@ readme = "../../README.md" keywords = ["rocket", "web", "framework", "http"] license = "MIT/Apache-2.0" categories = ["web-programming"] +edition = "2018" [features] default = [] diff --git a/core/http/src/accept.rs b/core/http/src/accept.rs @@ -4,9 +4,9 @@ use std::fmt; use smallvec::SmallVec; -use {Header, MediaType}; -use ext::IntoCollection; -use parse::parse_accept; +use crate::{Header, MediaType}; +use crate::ext::IntoCollection; +use crate::parse::parse_accept; /// A `MediaType` with an associated quality value. #[derive(Debug, Clone, PartialEq)] @@ -88,7 +88,7 @@ pub enum AcceptParams { Dynamic(SmallVec<[QMediaType; 1]>) } -impl ::pear::parsers::Collection for AcceptParams { +impl pear::parsers::Collection for AcceptParams { type Item = QMediaType; fn new() -> Self { @@ -130,7 +130,7 @@ impl PartialEq for AcceptParams { /// [`Request::accept()`] method. The [`preferred()`] method can be used to /// retrieve the client's preferred media type. /// -/// [`Request::accept`]: ::rocket::Request::accept() +/// [`Request::accept`]: rocket::Request::accept() /// [`preferred()`]: Accept::preferred() /// /// An `Accept` type with a single, common media type can be easily constructed @@ -353,7 +353,7 @@ impl Accept { } impl fmt::Display for Accept { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { for (i, media_type) in self.iter().enumerate() { if i >= 1 { write!(f, ", {}", media_type.0)?; @@ -387,7 +387,7 @@ impl Into<Header<'static>> for Accept { #[cfg(test)] mod test { - use {Accept, MediaType}; + use crate::{Accept, MediaType}; macro_rules! assert_preference { ($string:expr, $expect:expr) => ( diff --git a/core/http/src/content_type.rs b/core/http/src/content_type.rs @@ -3,10 +3,10 @@ use std::ops::Deref; use std::str::FromStr; use std::fmt; -use header::Header; -use media_type::{MediaType, Source}; -use ext::IntoCollection; -use hyper::mime::Mime; +use crate::header::Header; +use crate::media_type::{MediaType, Source}; +use crate::ext::IntoCollection; +use crate::hyper::mime::Mime; /// Representation of HTTP Content-Types. /// @@ -350,7 +350,7 @@ impl fmt::Display for ContentType { /// assert_eq!(ct, "application/json"); /// ``` #[inline(always)] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.0) } } diff --git a/core/http/src/cookies.rs b/core/http/src/cookies.rs @@ -1,7 +1,7 @@ use std::fmt; use std::cell::RefMut; -use Header; +use crate::Header; use cookie::Delta; #[doc(hidden)] pub use self::key::*; @@ -40,7 +40,7 @@ mod key { /// can be added or removed via the [`add()`], [`add_private()`], [`remove()`], /// and [`remove_private()`] methods. /// -/// [`Request::cookies()`]: ::rocket::Request::cookies() +/// [`Request::cookies()`]: rocket::Request::cookies() /// [`get()`]: #method.get /// [`get_private()`]: #method.get_private /// [`add()`]: #method.add @@ -84,10 +84,10 @@ mod key { /// // In practice, we'd probably fetch the user from the database. /// struct User(usize); /// -/// impl<'a, 'r> FromRequest<'a, 'r> for User { +/// impl FromRequest<'_, '_> for User { /// type Error = !; /// -/// fn from_request(request: &'a Request<'r>) -> request::Outcome<User, !> { +/// fn from_request(request: &Request<'_>) -> request::Outcome<User, !> { /// request.cookies() /// .get_private("user_id") /// .and_then(|cookie| cookie.value().parse().ok()) @@ -260,7 +260,7 @@ impl<'a> Cookies<'a> { /// WARNING: This is unstable! Do not use this method outside of Rocket! #[inline] #[doc(hidden)] - pub fn delta(&self) -> Delta { + pub fn delta(&self) -> Delta<'_> { match *self { Cookies::Jarred(ref jar, _) => jar.delta(), Cookies::Empty(ref jar) => jar.delta() @@ -269,7 +269,7 @@ impl<'a> Cookies<'a> { } #[cfg(feature = "private-cookies")] -impl<'a> Cookies<'a> { +impl Cookies<'_> { /// Returns a reference to the `Cookie` inside this collection with the name /// `name` and authenticates and decrypts the cookie's value, returning a /// `Cookie` with the decrypted value. If the cookie cannot be found, or the @@ -362,7 +362,7 @@ impl<'a> Cookies<'a> { } if cookie.expires().is_none() { - cookie.set_expires(::time::now() + ::time::Duration::weeks(1)); + cookie.set_expires(time::now() + time::Duration::weeks(1)); } if cookie.same_site().is_none() { @@ -400,8 +400,8 @@ impl<'a> Cookies<'a> { } } -impl<'a> fmt::Debug for Cookies<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl fmt::Debug for Cookies<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Cookies::Jarred(ref jar, _) => write!(f, "{:?}", jar), Cookies::Empty(ref jar) => write!(f, "{:?}", jar) @@ -409,14 +409,14 @@ impl<'a> fmt::Debug for Cookies<'a> { } } -impl<'c> From<Cookie<'c>> for Header<'static> { - fn from(cookie: Cookie) -> Header<'static> { +impl From<Cookie<'_>> for Header<'static> { + fn from(cookie: Cookie<'_>) -> Header<'static> { Header::new("Set-Cookie", cookie.encoded().to_string()) } } -impl<'a, 'c> From<&'a Cookie<'c>> for Header<'static> { - fn from(cookie: &Cookie) -> Header<'static> { +impl From<&Cookie<'_>> for Header<'static> { + fn from(cookie: &Cookie<'_>) -> Header<'static> { Header::new("Set-Cookie", cookie.encoded().to_string()) } } diff --git a/core/http/src/ext.rs b/core/http/src/ext.rs @@ -41,7 +41,7 @@ impl<T> IntoCollection<T> for Vec<T> { macro_rules! impl_for_slice { ($($size:tt)*) => ( - impl<'a, T: Clone> IntoCollection<T> for &'a [T $($size)*] { + impl<T: Clone> IntoCollection<T> for &[T $($size)*] { #[inline(always)] fn into_collection<A: Array<Item=T>>(self) -> SmallVec<A> { self.iter().cloned().collect() @@ -90,7 +90,7 @@ impl<T: IntoOwned> IntoOwned for Option<T> { } } -impl<'a, B: 'static + ToOwned + ?Sized> IntoOwned for Cow<'a, B> { +impl<B: 'static + ToOwned + ?Sized> IntoOwned for Cow<'_, B> { type Owned = Cow<'static, B>; #[inline(always)] @@ -104,7 +104,7 @@ use std::path::Path; // Outside of http, this is used by a test. #[doc(hidden)] pub trait Normalize { - fn normalized_str(&self) -> Cow<str>; + fn normalized_str(&self) -> Cow<'_, str>; } impl<T: AsRef<Path>> Normalize for T { @@ -114,7 +114,7 @@ impl<T: AsRef<Path>> Normalize for T { } #[cfg(not(windows))] - fn normalized_str(&self) -> Cow<str> { + fn normalized_str(&self) -> Cow<'_, str> { self.as_ref().to_string_lossy() } } diff --git a/core/http/src/header.rs b/core/http/src/header.rs @@ -3,7 +3,7 @@ use std::fmt; use indexmap::IndexMap; -use uncased::{Uncased, UncasedStr}; +use crate::uncased::{Uncased, UncasedStr}; /// Simple representation of an HTTP header. #[derive(Debug, Clone, Hash, PartialEq, Eq)] @@ -17,8 +17,9 @@ pub struct Header<'h> { impl<'h> Header<'h> { /// Constructs a new header. This method should be used rarely and only for /// non-standard headers. Instead, prefer to use the `Into<Header>` - /// implementations of many types, including [`ContentType`] and all of the - /// headers in [`http::hyper::header`](hyper::header). + /// implementations of many types, including + /// [`ContentType`](crate::ContentType) and all of the headers in + /// [`http::hyper::header`](hyper::header). /// /// # Examples /// @@ -104,9 +105,9 @@ impl<'h> Header<'h> { } } -impl<'h> fmt::Display for Header<'h> { +impl fmt::Display for Header<'_> { #[inline(always)] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}: {}", self.name, self.value) } } @@ -222,7 +223,7 @@ impl<'h> HeaderMap<'h> { /// assert_eq!(values.next(), None); /// ``` #[inline] - pub fn get<'a>(&'a self, name: &str) -> impl Iterator<Item=&'a str> { + pub fn get(&self, name: &str) -> impl Iterator<Item=&str> { self.headers .get(UncasedStr::new(name)) .into_iter() @@ -520,7 +521,7 @@ impl<'h> HeaderMap<'h> { /// ``` #[inline(always)] pub fn remove_all(&mut self) -> Vec<Header<'h>> { - let old_map = ::std::mem::replace(self, HeaderMap::new()); + let old_map = std::mem::replace(self, HeaderMap::new()); old_map.into_iter().collect() } @@ -560,7 +561,7 @@ impl<'h> HeaderMap<'h> { /// } /// } /// ``` - pub fn iter(&self) -> impl Iterator<Item=Header> { + pub fn iter(&self) -> impl Iterator<Item=Header<'_>> { self.headers.iter().flat_map(|(key, values)| { values.iter().map(move |val| { Header::new(key.as_str(), &**val) diff --git a/core/http/src/hyper.rs b/core/http/src/hyper.rs @@ -4,40 +4,38 @@ //! These types will, with certainty, be removed with time, but they reside here //! while necessary. -extern crate hyper; +#[doc(hidden)] pub use hyper::server::Request as Request; +#[doc(hidden)] pub use hyper::server::Response as Response; +#[doc(hidden)] pub use hyper::server::Server as Server; +#[doc(hidden)] pub use hyper::server::Handler as Handler; -#[doc(hidden)] pub use self::hyper::server::Request as Request; -#[doc(hidden)] pub use self::hyper::server::Response as Response; -#[doc(hidden)] pub use self::hyper::server::Server as Server; -#[doc(hidden)] pub use self::hyper::server::Handler as Handler; +#[doc(hidden)] pub use hyper::net; -#[doc(hidden)] pub use self::hyper::net; +#[doc(hidden)] pub use hyper::method::Method; +#[doc(hidden)] pub use hyper::status::StatusCode; +#[doc(hidden)] pub use hyper::error::Error; +#[doc(hidden)] pub use hyper::uri::RequestUri; +#[doc(hidden)] pub use hyper::http::h1; +#[doc(hidden)] pub use hyper::buffer; -#[doc(hidden)] pub use self::hyper::method::Method; -#[doc(hidden)] pub use self::hyper::status::StatusCode; -#[doc(hidden)] pub use self::hyper::error::Error; -#[doc(hidden)] pub use self::hyper::uri::RequestUri; -#[doc(hidden)] pub use self::hyper::http::h1; -#[doc(hidden)] pub use self::hyper::buffer; +pub use hyper::mime; -pub use self::hyper::mime; - -/// Type alias to `self::hyper::Response<'a, self::hyper::net::Fresh>`. +/// Type alias to `hyper::Response<'a, hyper::net::Fresh>`. #[doc(hidden)] pub type FreshResponse<'a> = self::Response<'a, self::net::Fresh>; /// Reexported Hyper header types. pub mod header { - use Header; + use crate::Header; - use super::hyper::header::Header as HyperHeaderTrait; + use hyper::header::Header as HyperHeaderTrait; macro_rules! import_hyper_items { - ($($item:ident),*) => ($(pub use super::hyper::header::$item;)*) + ($($item:ident),*) => ($(pub use hyper::header::$item;)*) } macro_rules! import_hyper_headers { ($($name:ident),*) => ($( - impl ::std::convert::From<self::$name> for Header<'static> { + impl std::convert::From<self::$name> for Header<'static> { fn from(header: self::$name) -> Header<'static> { Header::new($name::header_name(), header.to_string()) } diff --git a/core/http/src/lib.rs b/core/http/src/lib.rs @@ -4,6 +4,8 @@ #![feature(doc_cfg)] #![recursion_limit="512"] +#![warn(rust_2018_idioms)] + //! Types that map to concepts in HTTP. //! //! This module exports types that map to HTTP concepts or to the underlying @@ -13,13 +15,6 @@ //! [#17]: https://github.com/SergioBenitez/Rocket/issues/17 #[macro_use] extern crate pear; -extern crate percent_encoding; -extern crate smallvec; -extern crate cookie; -extern crate time; -extern crate indexmap; -extern crate state; -extern crate unicode_xid; pub mod hyper; pub mod uri; @@ -54,20 +49,20 @@ pub mod private { // We need to export these for codegen, but otherwise it's unnecessary. // TODO: Expose a `const fn` from ContentType when possible. (see RFC#1817) // FIXME(rustc): These show up in the rexported module. - pub use parse::Indexed; - pub use media_type::{MediaParams, Source}; + pub use crate::parse::Indexed; + pub use crate::media_type::{MediaParams, Source}; pub use smallvec::{SmallVec, Array}; // This one we need to expose for core. - pub use cookies::{Key, CookieJar}; + pub use crate::cookies::{Key, CookieJar}; } -pub use method::Method; -pub use content_type::ContentType; -pub use accept::{Accept, QMediaType}; -pub use status::{Status, StatusClass}; -pub use header::{Header, HeaderMap}; -pub use raw_str::RawStr; +pub use crate::method::Method; +pub use crate::content_type::ContentType; +pub use crate::accept::{Accept, QMediaType}; +pub use crate::status::{Status, StatusClass}; +pub use crate::header::{Header, HeaderMap}; +pub use crate::raw_str::RawStr; -pub use media_type::MediaType; -pub use cookies::{Cookie, SameSite, Cookies}; +pub use crate::media_type::MediaType; +pub use crate::cookies::{Cookie, SameSite, Cookies}; diff --git a/core/http/src/media_type.rs b/core/http/src/media_type.rs @@ -3,9 +3,9 @@ use std::str::FromStr; use std::fmt; use std::hash::{Hash, Hasher}; -use ext::IntoCollection; -use uncased::{uncased_eq, UncasedStr}; -use parse::{Indexed, IndexedString, parse_media_type}; +use crate::ext::IntoCollection; +use crate::uncased::{uncased_eq, UncasedStr}; +use crate::parse::{Indexed, IndexedString, parse_media_type}; use smallvec::SmallVec; @@ -22,7 +22,7 @@ pub enum MediaParams { Dynamic(SmallVec<[(IndexedString, IndexedString); 2]>) } -impl ::pear::parsers::Collection for MediaParams { +impl pear::parsers::Collection for MediaParams { type Item = (IndexedString, IndexedString); fn new() -> Self { @@ -60,11 +60,12 @@ impl Source { /// # Usage /// /// A `MediaType` should rarely be used directly. Instead, one is typically used -/// indirectly via types like [`Accept`] and [`ContentType`], which internally -/// contain `MediaType`s. Nonetheless, a `MediaType` can be created via the -/// [`MediaType::new()`], [`MediaType::with_params()`], and -/// [`MediaType::from_extension`()] methods. The preferred method, however, is -/// to create a `MediaType` via an associated constant. +/// indirectly via types like [`Accept`](crate::Accept) and +/// [`ContentType`](crate::ContentType), which internally contain `MediaType`s. +/// Nonetheless, a `MediaType` can be created via the [`MediaType::new()`], +/// [`MediaType::with_params()`], and [`MediaType::from_extension`()] methods. +/// The preferred method, however, is to create a `MediaType` via an associated +/// constant. /// /// ## Example /// @@ -533,7 +534,7 @@ impl Hash for MediaType { impl fmt::Display for MediaType { #[inline] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Source::Known(src) = self.source { src.fmt(f) } else { diff --git a/core/http/src/method.rs b/core/http/src/method.rs @@ -1,7 +1,7 @@ use std::fmt; use std::str::FromStr; -use {hyper, uncased::uncased_eq}; +use crate::{hyper, uncased::uncased_eq}; use self::Method::*; @@ -116,7 +116,7 @@ impl FromStr for Method { impl fmt::Display for Method { #[inline(always)] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.as_str().fmt(f) } } diff --git a/core/http/src/parse/accept.rs b/core/http/src/parse/accept.rs @@ -1,12 +1,12 @@ use pear::parser; use pear::parsers::*; -use {Accept, QMediaType}; -use parse::checkers::is_whitespace; -use parse::media_type::media_type; +use crate::{Accept, QMediaType}; +use crate::parse::checkers::is_whitespace; +use crate::parse::media_type::media_type; -type Input<'a> = ::parse::IndexedInput<'a, str>; -type Result<'a, T> = ::pear::Result<T, Input<'a>>; +type Input<'a> = crate::parse::IndexedInput<'a, str>; +type Result<'a, T> = pear::Result<T, Input<'a>>; #[parser] fn weighted_media_type<'a>(input: &mut Input<'a>) -> Result<'a, QMediaType> { @@ -29,13 +29,13 @@ fn accept<'a>(input: &mut Input<'a>) -> Result<'a, Accept> { Accept(series(false, ',', is_whitespace, weighted_media_type)?) } -pub fn parse_accept(input: &str) -> Result<Accept> { +pub fn parse_accept(input: &str) -> Result<'_, Accept> { parse!(accept: &mut input.into()) } #[cfg(test)] mod test { - use MediaType; + use crate::MediaType; use super::parse_accept; macro_rules! assert_parse { diff --git a/core/http/src/parse/checkers.rs b/core/http/src/parse/checkers.rs @@ -6,7 +6,7 @@ pub fn is_whitespace(byte: char) -> bool { #[inline] pub fn is_valid_token(c: char) -> bool { match c { - '0'...'9' | 'A'...'Z' | '^'...'~' | '#'...'\'' + '0'..='9' | 'A'..='Z' | '^'..='~' | '#'..='\'' | '!' | '*' | '+' | '-' | '.' => true, _ => false } diff --git a/core/http/src/parse/indexed.rs b/core/http/src/parse/indexed.rs @@ -6,7 +6,7 @@ use std::fmt::{self, Debug}; use pear::{Input, Length}; -use ext::IntoOwned; +use crate::ext::IntoOwned; pub type IndexedString = Indexed<'static, str>; pub type IndexedStr<'a> = Indexed<'a, str>; @@ -31,7 +31,7 @@ impl AsPtr for [u8] { } #[derive(PartialEq)] -pub enum Indexed<'a, T: ?Sized + ToOwned + 'a> { +pub enum Indexed<'a, T: ?Sized + ToOwned> { Indexed(usize, usize), Concrete(Cow<'a, T>) } @@ -72,7 +72,7 @@ impl<'a, T: ?Sized + ToOwned + 'a> Indexed<'a, T> { } } -impl<'a, T: 'static + ?Sized + ToOwned> IntoOwned for Indexed<'a, T> { +impl<T: 'static + ?Sized + ToOwned> IntoOwned for Indexed<'_, T> { type Owned = Indexed<'static, T>; fn into_owned(self) -> Indexed<'static, T> { @@ -154,7 +154,7 @@ impl<'a, T: ?Sized + ToOwned + 'a> Indexed<'a, T> /// /// Panics if `self` is an indexed string and `string` is None. // pub fn to_source(&self, source: Option<&'a T>) -> &T { - pub fn from_cow_source<'s>(&'s self, source: &'s Option<Cow<T>>) -> &'s T { + pub fn from_cow_source<'s>(&'s self, source: &'s Option<Cow<'_, T>>) -> &'s T { if self.is_indexed() && source.is_none() { panic!("Cannot convert indexed str to str without base string!") } @@ -196,7 +196,7 @@ impl<'a, T: ToOwned + ?Sized + 'a> Clone for Indexed<'a, T> { impl<'a, T: ?Sized + 'a> Debug for Indexed<'a, T> where T: ToOwned + Debug, T::Owned: Debug { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Indexed::Indexed(a, b) => fmt::Debug::fmt(&(a, b), f), Indexed::Concrete(ref cow) => fmt::Debug::fmt(cow, f), @@ -215,7 +215,7 @@ impl<'a, T: ?Sized + Length + ToOwned + 'a> Length for Indexed<'a, T> { } #[derive(Debug)] -pub struct IndexedInput<'a, T: ?Sized + 'a> { +pub struct IndexedInput<'a, T: ?Sized> { source: &'a T, current: &'a T } @@ -234,8 +234,8 @@ impl<'a, T: ToOwned + ?Sized + 'a> IndexedInput<'a, T> { } } -impl<'a> IndexedInput<'a, [u8]> { - pub fn backtrack(&mut self, n: usize) -> ::pear::Result<(), Self> { +impl IndexedInput<'_, [u8]> { + pub fn backtrack(&mut self, n: usize) -> pear::Result<(), Self> { let source_addr = self.source.as_ptr() as usize; let current_addr = self.current.as_ptr() as usize; if current_addr > n && (current_addr - n) >= source_addr { @@ -323,8 +323,8 @@ pub struct Context { pub string: String } -impl ::std::fmt::Display for Context { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl std::fmt::Display for Context { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { const LIMIT: usize = 7; write!(f, "[{}:]", self.offset)?; diff --git a/core/http/src/parse/media_type.rs b/core/http/src/parse/media_type.rs @@ -3,12 +3,12 @@ use std::borrow::Cow; use pear::{parser, switch}; use pear::parsers::*; -use media_type::{MediaType, Source}; -use parse::checkers::{is_whitespace, is_valid_token}; -use parse::IndexedStr; +use crate::media_type::{MediaType, Source}; +use crate::parse::checkers::{is_whitespace, is_valid_token}; +use crate::parse::IndexedStr; -type Input<'a> = ::parse::IndexedInput<'a, str>; -type Result<'a, T> = ::pear::Result<T, Input<'a>>; +type Input<'a> = crate::parse::IndexedInput<'a, str>; +type Result<'a, T> = pear::Result<T, Input<'a>>; #[parser] fn quoted_string<'a>(input: &mut Input<'a>) -> Result<'a, IndexedStr<'a>> { @@ -54,13 +54,13 @@ pub fn media_type<'a>(input: &mut Input<'a>) -> Result<'a, MediaType> { } } -pub fn parse_media_type(input: &str) -> Result<MediaType> { +pub fn parse_media_type(input: &str) -> Result<'_, MediaType> { parse!(media_type: &mut input.into()) } #[cfg(test)] mod test { - use MediaType; + use crate::MediaType; use super::parse_media_type; macro_rules! assert_no_parse { diff --git a/core/http/src/parse/uri/error.rs b/core/http/src/parse/uri/error.rs @@ -2,9 +2,9 @@ use std::fmt; use std::borrow::Cow; use pear::{ParseErr, Expected}; -use parse::indexed::Context; -use parse::uri::RawInput; -use ext::IntoOwned; +use crate::parse::indexed::Context; +use crate::parse::uri::RawInput; +use crate::ext::IntoOwned; /// Error emitted on URI parse failure. /// @@ -58,7 +58,7 @@ impl<'a> Error<'a> { } impl fmt::Display for Or<char, u8> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Or::A(left) => write!(f, "'{}'", left), Or::B(right) => write!(f, "non-ASCII byte {}", right), @@ -66,8 +66,8 @@ impl fmt::Display for Or<char, u8> { } } -impl<'a> fmt::Display for Error<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl fmt::Display for Error<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // This relies on specialization of the `Display` impl for `Expected`. write!(f, "{}", self.expected)?; @@ -79,7 +79,7 @@ impl<'a> fmt::Display for Error<'a> { } } -impl<'a> IntoOwned for Error<'a> { +impl IntoOwned for Error<'_> { type Owned = Error<'static>; fn into_owned(self) -> Self::Owned { @@ -90,7 +90,7 @@ impl<'a> IntoOwned for Error<'a> { #[cfg(test)] mod tests { - use parse::uri::origin_from_str; + use crate::parse::uri::origin_from_str; macro_rules! check_err { ($url:expr => $error:expr) => {{ diff --git a/core/http/src/parse/uri/mod.rs b/core/http/src/parse/uri/mod.rs @@ -4,8 +4,8 @@ mod tables; #[cfg(test)] mod tests; -use uri::{Uri, Origin, Absolute, Authority}; -use parse::indexed::IndexedInput; +use crate::uri::{Uri, Origin, Absolute, Authority}; +use crate::parse::indexed::IndexedInput; use self::parser::{uri, origin, authority_only, absolute_only, rocket_route_origin}; crate use self::tables::is_pchar; @@ -14,31 +14,31 @@ pub use self::error::Error; type RawInput<'a> = IndexedInput<'a, [u8]>; #[inline] -pub fn from_str(string: &str) -> Result<Uri, Error> { +pub fn from_str(string: &str) -> Result<Uri<'_>, Error<'_>> { parse!(uri: &mut RawInput::from(string.as_bytes())) .map_err(|e| Error::from(string, e)) } #[inline] -pub fn origin_from_str(string: &str) -> Result<Origin, Error> { +pub fn origin_from_str(string: &str) -> Result<Origin<'_>, Error<'_>> { parse!(origin: &mut RawInput::from(string.as_bytes())) .map_err(|e| Error::from(string, e)) } #[inline] -pub fn route_origin_from_str(string: &str) -> Result<Origin, Error> { +pub fn route_origin_from_str(string: &str) -> Result<Origin<'_>, Error<'_>> { parse!(rocket_route_origin: &mut RawInput::from(string.as_bytes())) .map_err(|e| Error::from(string, e)) } #[inline] -pub fn authority_from_str(string: &str) -> Result<Authority, Error> { +pub fn authority_from_str(string: &str) -> Result<Authority<'_>, Error<'_>> { parse!(authority_only: &mut RawInput::from(string.as_bytes())) .map_err(|e| Error::from(string, e)) } #[inline] -pub fn absolute_from_str(string: &str) -> Result<Absolute, Error> { +pub fn absolute_from_str(string: &str) -> Result<Absolute<'_>, Error<'_>> { parse!(absolute_only: &mut RawInput::from(string.as_bytes())) .map_err(|e| Error::from(string, e)) } diff --git a/core/http/src/parse/uri/parser.rs b/core/http/src/parse/uri/parser.rs @@ -1,12 +1,12 @@ use pear::parsers::*; use pear::{parser, switch}; -use uri::{Uri, Origin, Authority, Absolute, Host}; -use parse::uri::tables::{is_reg_name_char, is_pchar, is_pchar_or_rchar}; -use parse::uri::RawInput; -use parse::IndexedBytes; +use crate::uri::{Uri, Origin, Authority, Absolute, Host}; +use crate::parse::uri::tables::{is_reg_name_char, is_pchar, is_pchar_or_rchar}; +use crate::parse::uri::RawInput; +use crate::parse::IndexedBytes; -type Result<'a, T> = ::pear::Result<T, RawInput<'a>>; +type Result<'a, T> = pear::Result<T, RawInput<'a>>; #[parser] crate fn uri<'a>(input: &mut RawInput<'a>) -> Result<'a, Uri<'a>> { diff --git a/core/http/src/parse/uri/tests.rs b/core/http/src/parse/uri/tests.rs @@ -1,6 +1,6 @@ -use uri::{Uri, Origin, Authority, Absolute}; -use parse::uri::*; -use uri::Host::*; +use crate::uri::{Uri, Origin, Authority, Absolute}; +use crate::parse::uri::*; +use crate::uri::Host::*; macro_rules! assert_parse_eq { ($($from:expr => $to:expr),+) => ( diff --git a/core/http/src/raw_str.rs b/core/http/src/raw_str.rs @@ -5,7 +5,7 @@ use std::cmp::Ordering; use std::str::Utf8Error; use std::fmt; -use uncased::UncasedStr; +use crate::uncased::UncasedStr; /// A reference to a string inside of a raw HTTP message. /// @@ -47,8 +47,8 @@ use uncased::UncasedStr; /// encounter an `&RawStr` as a parameter via [`FromParam`] or as a form value /// via [`FromFormValue`]. /// -/// [`FromParam`]: ::rocket::request::FromParam -/// [`FromFormValue`]: ::rocket::request::FromFormValue +/// [`FromParam`]: rocket::request::FromParam +/// [`FromFormValue`]: rocket::request::FromFormValue #[repr(transparent)] #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct RawStr(str); @@ -98,13 +98,13 @@ impl RawStr { /// use rocket::http::RawStr; /// /// // Note: Rocket should never hand you a bad `&RawStr`. - /// let bad_str = unsafe { ::std::str::from_utf8_unchecked(b"a=\xff") }; + /// let bad_str = unsafe { std::str::from_utf8_unchecked(b"a=\xff") }; /// let bad_raw_str = RawStr::from_str(bad_str); /// assert!(bad_raw_str.percent_decode().is_err()); /// ``` #[inline(always)] - pub fn percent_decode(&self) -> Result<Cow<str>, Utf8Error> { - ::percent_encoding::percent_decode(self.as_bytes()).decode_utf8() + pub fn percent_decode(&self) -> Result<Cow<'_, str>, Utf8Error> { + percent_encoding::percent_decode(self.as_bytes()).decode_utf8() } /// Returns a percent-decoded version of the string. Any invalid UTF-8 @@ -131,13 +131,13 @@ impl RawStr { /// use rocket::http::RawStr; /// /// // Note: Rocket should never hand you a bad `&RawStr`. - /// let bad_str = unsafe { ::std::str::from_utf8_unchecked(b"a=\xff") }; + /// let bad_str = unsafe { std::str::from_utf8_unchecked(b"a=\xff") }; /// let bad_raw_str = RawStr::from_str(bad_str); /// assert_eq!(bad_raw_str.percent_decode_lossy(), "a=�"); /// ``` #[inline(always)] - pub fn percent_decode_lossy(&self) -> Cow<str> { - ::percent_encoding::percent_decode(self.as_bytes()).decode_utf8_lossy() + pub fn percent_decode_lossy(&self) -> Cow<'_, str> { + percent_encoding::percent_decode(self.as_bytes()).decode_utf8_lossy() } /// Returns a URL-decoded version of the string. This is identical to @@ -193,7 +193,7 @@ impl RawStr { /// use rocket::http::RawStr; /// /// // Note: Rocket should never hand you a bad `&RawStr`. - /// let bad_str = unsafe { ::std::str::from_utf8_unchecked(b"a+b=\xff") }; + /// let bad_str = unsafe { std::str::from_utf8_unchecked(b"a+b=\xff") }; /// let bad_raw_str = RawStr::from_str(bad_str); /// assert_eq!(bad_raw_str.url_decode_lossy(), "a b=�"); /// ``` @@ -245,7 +245,7 @@ impl RawStr { /// let escaped = raw_str.html_escape(); /// assert_eq!(escaped, "大阪"); /// ``` - pub fn html_escape(&self) -> Cow<str> { + pub fn html_escape(&self) -> Cow<'_, str> { let mut escaped = false; let mut allocated = Vec::new(); // this is allocation free for c in self.as_bytes() { @@ -373,7 +373,7 @@ impl PartialEq<String> for RawStr { } } -impl<'a> PartialEq<String> for &'a RawStr { +impl PartialEq<String> for &'_ RawStr { #[inline(always)] fn eq(&self, other: &String) -> bool { self.as_str() == other.as_str() @@ -426,7 +426,7 @@ impl DerefMut for RawStr { impl fmt::Display for RawStr { #[inline(always)] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } diff --git a/core/http/src/route.rs b/core/http/src/route.rs @@ -1,10 +1,11 @@ use std::borrow::Cow; use std::marker::PhantomData; + use unicode_xid::UnicodeXID; -use ext::IntoOwned; -use uri::{Origin, UriPart, Path, Query}; -use uri::encoding::unsafe_percent_encode; +use crate::ext::IntoOwned; +use crate::uri::{Origin, UriPart, Path, Query}; +use crate::uri::encoding::unsafe_percent_encode; use self::Error::*; @@ -32,7 +33,7 @@ pub struct RouteSegment<'a, P: UriPart> { _part: PhantomData<P>, } -impl<'a, P: UriPart + 'static> IntoOwned for RouteSegment<'a, P> { +impl<P: UriPart + 'static> IntoOwned for RouteSegment<'_, P> { type Owned = RouteSegment<'static, P>; #[inline] @@ -86,7 +87,7 @@ fn is_valid_ident(string: &str) -> bool { } impl<'a, P: UriPart> RouteSegment<'a, P> { - pub fn parse_one(segment: &'a str) -> Result<Self, Error> { + pub fn parse_one(segment: &'a str) -> Result<Self, Error<'_>> { let (string, index) = (segment.into(), None); // Check if this is a dynamic param. If so, check its well-formedness. @@ -129,7 +130,7 @@ impl<'a, P: UriPart> RouteSegment<'a, P> { pub fn parse_many( string: &'a str, - ) -> impl Iterator<Item = SResult<P>> { + ) -> impl Iterator<Item = SResult<'_, P>> { let mut last_multi_seg: Option<&str> = None; string.split(P::DELIMITER) .filter(|s| !s.is_empty()) @@ -151,13 +152,13 @@ impl<'a, P: UriPart> RouteSegment<'a, P> { } impl<'a> RouteSegment<'a, Path> { - pub fn parse(uri: &'a Origin) -> impl Iterator<Item = SResult<'a, Path>> { + pub fn parse(uri: &'a Origin<'_>) -> impl Iterator<Item = SResult<'a, Path>> { Self::parse_many(uri.path()) } } impl<'a> RouteSegment<'a, Query> { - pub fn parse(uri: &'a Origin) -> Option<impl Iterator<Item = SResult<'a, Query>>> { + pub fn parse(uri: &'a Origin<'_>) -> Option<impl Iterator<Item = SResult<'a, Query>>> { uri.query().map(|q| Self::parse_many(q)) } } diff --git a/core/http/src/status.rs b/core/http/src/status.rs @@ -273,7 +273,7 @@ impl Status { impl fmt::Display for Status { #[inline(always)] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{} {}", self.code, self.reason) } } diff --git a/core/http/src/tls.rs b/core/http/src/tls.rs @@ -1,5 +1,2 @@ -extern crate rustls; -extern crate hyper_sync_rustls; - -pub use self::hyper_sync_rustls::{util, WrappedStream, ServerSession, TlsServer}; -pub use self::rustls::{Certificate, PrivateKey}; +pub use hyper_sync_rustls::{util, WrappedStream, ServerSession, TlsServer}; +pub use rustls::{Certificate, PrivateKey}; diff --git a/core/http/src/uncased.rs b/core/http/src/uncased.rs @@ -107,14 +107,14 @@ impl PartialEq<UncasedStr> for str { } } -impl<'a> PartialEq<&'a str> for UncasedStr { +impl PartialEq<&str> for UncasedStr { #[inline(always)] - fn eq(&self, other: & &'a str) -> bool { + fn eq(&self, other: &&str) -> bool { self.0.eq_ignore_ascii_case(other) } } -impl<'a> PartialEq<UncasedStr> for &'a str { +impl PartialEq<UncasedStr> for &str { #[inline(always)] fn eq(&self, other: &UncasedStr) -> bool { other.0.eq_ignore_ascii_case(self) @@ -156,7 +156,7 @@ impl Ord for UncasedStr { impl fmt::Display for UncasedStr { #[inline(always)] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } @@ -233,7 +233,7 @@ impl<'s> Uncased<'s> { } } -impl<'a> Deref for Uncased<'a> { +impl Deref for Uncased<'_> { type Target = UncasedStr; #[inline(always)] @@ -242,14 +242,14 @@ impl<'a> Deref for Uncased<'a> { } } -impl<'a> AsRef<UncasedStr> for Uncased<'a>{ +impl AsRef<UncasedStr> for Uncased<'_>{ #[inline(always)] fn as_ref(&self) -> &UncasedStr { UncasedStr::new(self.string.borrow()) } } -impl<'a> Borrow<UncasedStr> for Uncased<'a> { +impl Borrow<UncasedStr> for Uncased<'_> { #[inline(always)] fn borrow(&self) -> &UncasedStr { self.as_str().into() @@ -284,64 +284,64 @@ impl<'s, 'c: 's, T: Into<Cow<'c, str>>> From<T> for Uncased<'s> { } } -impl<'a, 'b> PartialOrd<Uncased<'b>> for Uncased<'a> { +impl<'b> PartialOrd<Uncased<'b>> for Uncased<'_> { #[inline(always)] fn partial_cmp(&self, other: &Uncased<'b>) -> Option<Ordering> { self.as_ref().partial_cmp(other.as_ref()) } } -impl<'a> Ord for Uncased<'a> { +impl Ord for Uncased<'_> { fn cmp(&self, other: &Self) -> Ordering { self.as_ref().cmp(other.as_ref()) } } -impl<'s> fmt::Display for Uncased<'s> { +impl fmt::Display for Uncased<'_> { #[inline(always)] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.string.fmt(f) } } -impl<'a, 'b> PartialEq<Uncased<'b>> for Uncased<'a> { +impl<'b> PartialEq<Uncased<'b>> for Uncased<'_> { #[inline(always)] fn eq(&self, other: &Uncased<'b>) -> bool { self.as_ref().eq(other.as_ref()) } } -impl<'a> PartialEq<str> for Uncased<'a> { +impl PartialEq<str> for Uncased<'_> { #[inline(always)] fn eq(&self, other: &str) -> bool { self.as_ref().eq(other) } } -impl<'b> PartialEq<Uncased<'b>> for str { +impl PartialEq<Uncased<'_>> for str { #[inline(always)] - fn eq(&self, other: &Uncased<'b>) -> bool { + fn eq(&self, other: &Uncased<'_>) -> bool { other.as_ref().eq(self) } } -impl<'a, 'b> PartialEq<&'b str> for Uncased<'a> { +impl<'b> PartialEq<&'b str> for Uncased<'_> { #[inline(always)] fn eq(&self, other: & &'b str) -> bool { self.as_ref().eq(other) } } -impl<'a, 'b> PartialEq<Uncased<'b>> for &'a str { +impl<'b> PartialEq<Uncased<'b>> for &str { #[inline(always)] fn eq(&self, other: &Uncased<'b>) -> bool { other.as_ref().eq(self) } } -impl<'s> Eq for Uncased<'s> { } +impl Eq for Uncased<'_> { } -impl<'s> Hash for Uncased<'s> { +impl Hash for Uncased<'_> { #[inline(always)] fn hash<H: Hasher>(&self, hasher: &mut H) { self.as_ref().hash(hasher) diff --git a/core/http/src/uri/absolute.rs b/core/http/src/uri/absolute.rs @@ -1,9 +1,9 @@ use std::borrow::Cow; use std::fmt::{self, Display}; -use ext::IntoOwned; -use parse::{Indexed, IndexedStr}; -use uri::{Authority, Origin, Error, as_utf8_unchecked}; +use crate::ext::IntoOwned; +use crate::parse::{Indexed, IndexedStr}; +use crate::uri::{Authority, Origin, Error, as_utf8_unchecked}; /// A URI with a scheme, authority, path, and query: /// `http://user:pass@domain.com:4444/path?query`. @@ -29,7 +29,7 @@ pub struct Absolute<'a> { origin: Option<Origin<'a>>, } -impl<'a> IntoOwned for Absolute<'a> { +impl IntoOwned for Absolute<'_> { type Owned = Absolute<'static>; fn into_owned(self) -> Self::Owned { @@ -85,7 +85,7 @@ impl<'a> Absolute<'a> { /// assert_eq!(uri.origin(), None); /// ``` pub fn parse(string: &'a str) -> Result<Absolute<'a>, Error<'a>> { - ::parse::uri::absolute_from_str(string) + crate::parse::uri::absolute_from_str(string) } /// Returns the scheme part of the absolute URI. @@ -149,7 +149,7 @@ impl<'a> Absolute<'a> { } } -impl<'a, 'b> PartialEq<Absolute<'b>> for Absolute<'a> { +impl<'b> PartialEq<Absolute<'b>> for Absolute<'_> { fn eq(&self, other: &Absolute<'b>) -> bool { self.scheme() == other.scheme() && self.authority() == other.authority() @@ -157,8 +157,8 @@ impl<'a, 'b> PartialEq<Absolute<'b>> for Absolute<'a> { } } -impl<'a> Display for Absolute<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl Display for Absolute<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.scheme())?; match self.authority { Some(ref authority) => write!(f, "://{}", authority)?, diff --git a/core/http/src/uri/authority.rs b/core/http/src/uri/authority.rs @@ -1,9 +1,9 @@ use std::fmt::{self, Display}; use std::borrow::Cow; -use ext::IntoOwned; -use parse::{Indexed, IndexedStr}; -use uri::{as_utf8_unchecked, Error}; +use crate::ext::IntoOwned; +use crate::parse::{Indexed, IndexedStr}; +use crate::uri::{as_utf8_unchecked, Error}; /// A URI with an authority only: `user:pass@host:8000`. /// @@ -41,7 +41,7 @@ impl<T: IntoOwned> IntoOwned for Host<T> { } } -impl<'a> IntoOwned for Authority<'a> { +impl IntoOwned for Authority<'_> { type Owned = Authority<'static>; fn into_owned(self) -> Authority<'static> { @@ -102,7 +102,7 @@ impl<'a> Authority<'a> { /// Authority::parse("http://google.com").expect_err("invalid authority"); /// ``` pub fn parse(string: &'a str) -> Result<Authority<'a>, Error<'a>> { - ::parse::uri::authority_from_str(string) + crate::parse::uri::authority_from_str(string) } /// Returns the user info part of the authority URI, if there is one. @@ -171,7 +171,7 @@ impl<'a> Authority<'a> { } } -impl<'a, 'b> PartialEq<Authority<'b>> for Authority<'a> { +impl<'b> PartialEq<Authority<'b>> for Authority<'_> { fn eq(&self, other: &Authority<'b>) -> bool { self.user_info() == other.user_info() && self.host() == other.host() @@ -180,8 +180,8 @@ impl<'a, 'b> PartialEq<Authority<'b>> for Authority<'a> { } } -impl<'a> Display for Authority<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl Display for Authority<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(user_info) = self.user_info() { write!(f, "{}@", user_info)?; } diff --git a/core/http/src/uri/encoding.rs b/core/http/src/uri/encoding.rs @@ -3,8 +3,8 @@ use std::borrow::Cow; use percent_encoding::{EncodeSet, utf8_percent_encode}; -use uri::{UriPart, Path, Query}; -use parse::uri::is_pchar; +use crate::uri::{UriPart, Path, Query}; +use crate::parse::uri::is_pchar; #[derive(Clone, Copy)] #[allow(non_camel_case_types)] @@ -62,7 +62,7 @@ impl EncodeSet for DEFAULT_ENCODE_SET { } } -crate fn unsafe_percent_encode<P: UriPart>(string: &str) -> Cow<str> { +crate fn unsafe_percent_encode<P: UriPart>(string: &str) -> Cow<'_, str> { match P::DELIMITER { '/' => percent_encode::<UNSAFE_ENCODE_SET<Path>>(string), '&' => percent_encode::<UNSAFE_ENCODE_SET<Query>>(string), @@ -70,6 +70,6 @@ crate fn unsafe_percent_encode<P: UriPart>(string: &str) -> Cow<str> { } } -crate fn percent_encode<S: EncodeSet + Default>(string: &str) -> Cow<str> { +crate fn percent_encode<S: EncodeSet + Default>(string: &str) -> Cow<'_, str> { utf8_percent_encode(string, S::default()).into() } diff --git a/core/http/src/uri/formatter.rs b/core/http/src/uri/formatter.rs @@ -3,7 +3,7 @@ use std::marker::PhantomData; use smallvec::SmallVec; -use uri::{UriPart, Path, Query, UriDisplay, Origin}; +use crate::uri::{UriPart, Path, Query, UriDisplay, Origin}; /// A struct used to format strings for [`UriDisplay`]. /// @@ -16,9 +16,9 @@ use uri::{UriPart, Path, Query, UriDisplay, Origin}; /// formatting parameters in the query part of the URI. The /// [`write_named_value()`] method is only available to `UriDisplay<Query>`. /// -/// [`UriPart`]: uri::UriPart -/// [`Path`]: uri::Path -/// [`Query`]: uri::Query +/// [`UriPart`]: crate::uri::UriPart +/// [`Path`]: crate::uri::Path +/// [`Query`]: crate::uri::Query /// /// # Overview /// @@ -39,9 +39,9 @@ use uri::{UriPart, Path, Query, UriDisplay, Origin}; /// calls `write_named_vlaue()`, the nested names are joined by a `.`, /// written out followed by a `=`, followed by the value. /// -/// [`UriDisplay`]: uri::UriDisplay -/// [`UriDisplay::fmt()`]: uri::UriDisplay::fmt() -/// [`write_named_value()`]: uri::Formatter::write_named_value() +/// [`UriDisplay`]: crate::uri::UriDisplay +/// [`UriDisplay::fmt()`]: crate::uri::UriDisplay::fmt() +/// [`write_named_value()`]: crate::uri::Formatter::write_named_value() /// /// # Usage /// @@ -59,7 +59,7 @@ use uri::{UriPart, Path, Query, UriDisplay, Origin}; /// called, after a call to `write_named_value` or `write_value`, or after a /// call to [`refresh()`]. /// -/// [`refresh()`]: uri::Formatter::refresh() +/// [`refresh()`]: crate::uri::Formatter::refresh() /// /// # Example /// @@ -146,8 +146,8 @@ use uri::{UriPart, Path, Query, UriDisplay, Origin}; /// assert_eq!(uri_string, "number=42+47"); /// ``` /// -/// [`write_value()`]: uri::Formatter::write_value() -/// [`write_raw()`]: uri::Formatter::write_raw() +/// [`write_value()`]: crate::uri::Formatter::write_value() +/// [`write_raw()`]: crate::uri::Formatter::write_raw() pub struct Formatter<'i, P: UriPart> { prefixes: SmallVec<[&'static str; 3]>, inner: &'i mut (dyn Write + 'i), @@ -330,7 +330,7 @@ impl<'i, P: UriPart> Formatter<'i, P> { } } -impl<'i> Formatter<'i, Query> { +impl Formatter<'_, Query> { fn with_prefix<F>(&mut self, prefix: &str, f: F) -> fmt::Result where F: FnOnce(&mut Self) -> fmt::Result { @@ -347,7 +347,7 @@ impl<'i> Formatter<'i, Query> { // // Said succinctly: this `prefixes` stack shadows a subset of the // `with_prefix` stack precisely, making it reachable to other code. - let prefix: &'static str = unsafe { ::std::mem::transmute(prefix) }; + let prefix: &'static str = unsafe { std::mem::transmute(prefix) }; self.prefixes.push(prefix); let result = f(self); @@ -392,7 +392,7 @@ impl<'i> Formatter<'i, Query> { } } -impl<'i, P: UriPart> fmt::Write for Formatter<'i, P> { +impl<P: UriPart> fmt::Write for Formatter<'_, P> { fn write_str(&mut self, s: &str) -> fmt::Result { self.write_raw(s) } @@ -421,7 +421,7 @@ pub struct UriArguments<'a> { } // Used by code generation. -impl<'a> UriArguments<'a> { +impl UriArguments<'_> { #[doc(hidden)] pub fn into_origin(self) -> Origin<'static> { use std::borrow::Cow; diff --git a/core/http/src/uri/from_uri_param.rs b/core/http/src/uri/from_uri_param.rs @@ -1,7 +1,7 @@ use std::path::{Path, PathBuf}; -use RawStr; -use uri::{self, UriPart, UriDisplay}; +use crate::RawStr; +use crate::uri::{self, UriPart, UriDisplay}; /// Conversion trait for parameters used in [`uri!`] invocations. /// @@ -136,7 +136,7 @@ use uri::{self, UriPart, UriDisplay}; /// nickname: String, /// } /// -/// impl<'a> UriDisplay<Query> for User<'a> { +/// impl UriDisplay<Query> for User<'_> { /// fn fmt(&self, f: &mut Formatter<Query>) -> fmt::Result { /// f.write_named_value("name", &self.name)?; /// f.write_named_value("nickname", &self.nickname) @@ -165,7 +165,7 @@ use uri::{self, UriPart, UriDisplay}; /// # #[derive(FromForm)] /// # struct User<'a> { name: &'a RawStr, nickname: String, } /// # -/// # impl<'a> UriDisplay<Query> for User<'a> { +/// # impl UriDisplay<Query> for User<'_> { /// # fn fmt(&self, f: &mut Formatter<Query>) -> fmt::Result { /// # f.write_named_value("name", &self.name)?; /// # f.write_named_value("nickname", &self.nickname) @@ -187,17 +187,17 @@ use uri::{self, UriPart, UriDisplay}; /// assert_eq!(uri.query(), Some("name=Robert%20Mike&nickname=Bob")); /// ``` /// -/// [`uri!`]: ::rocket_codegen::uri -/// [`UriDisplay`]: uri::UriDisplay -/// [`FromUriParam::Target`]: uri::FromUriParam::Target -/// [`Path`]: uri::Path +/// [`uri!`]: rocket_codegen::uri +/// [`UriDisplay`]: crate::uri::UriDisplay +/// [`FromUriParam::Target`]: crate::uri::FromUriParam::Target +/// [`Path`]: crate::uri::Path pub trait FromUriParam<P: UriPart, T> { /// The resulting type of this conversion. type Target: UriDisplay<P>; /// Converts a value of type `T` into a value of type `Self::Target`. The /// resulting value of type `Self::Target` will be rendered into a URI using - /// its [`UriDisplay`](uri::UriDisplay) implementation. + /// its [`UriDisplay`](crate::uri::UriDisplay) implementation. fn from_uri_param(param: T) -> Self::Target; } @@ -277,9 +277,9 @@ macro_rules! impl_conversion_ref { /// * Example: `impl_from_uri_param_identity!([Path] ('a) MyType<'a>);` /// * Generates: `impl<'a> FromUriParam<Path, _> for MyType<'a> { ... }` /// -/// [`FromUriParam`]: uri::FromUriParam -/// [`Path`]: uri::Path -/// [`Query`]: uri::Query +/// [`FromUriParam`]: crate::uri::FromUriParam +/// [`Path`]: crate::uri::Path +/// [`Query`]: crate::uri::Query #[macro_export(local_inner_macros)] macro_rules! impl_from_uri_param_identity { ($(($($l:tt)*) $T:ty),*) => ($( impl_conversion_ref!(($($l)*) $T => $T); )*); diff --git a/core/http/src/uri/mod.rs b/core/http/src/uri/mod.rs @@ -11,7 +11,7 @@ mod segments; crate mod encoding; -pub use parse::uri::Error; +pub use crate::parse::uri::Error; pub use self::uri::*; pub use self::authority::*; @@ -48,10 +48,10 @@ mod private { /// approach enables succinct, type-checked generic implementations of these /// items. /// -/// [`Query`]: uri::Query -/// [`Path`]: uri::Path -/// [`UriDisplay`]: uri::UriDisplay -/// [`Formatter`]: uri::Formatter +/// [`Query`]: crate::uri::Query +/// [`Path`]: crate::uri::Path +/// [`UriDisplay`]: crate::uri::UriDisplay +/// [`Formatter`]: crate::uri::Formatter pub trait UriPart: private::Sealed { const DELIMITER: char; } @@ -66,7 +66,7 @@ pub trait UriPart: private::Sealed { /// ^------------------ Path /// ``` /// -/// [`UriPart`]: uri::UriPart +/// [`UriPart`]: crate::uri::UriPart #[derive(Debug, Clone, Copy)] pub enum Path { } @@ -79,7 +79,7 @@ pub enum Path { } /// ^-------------- Query /// ``` /// -/// [`UriPart`]: uri::UriPart +/// [`UriPart`]: crate::uri::UriPart #[derive(Debug, Clone, Copy)] pub enum Query { } diff --git a/core/http/src/uri/origin.rs b/core/http/src/uri/origin.rs @@ -1,9 +1,9 @@ use std::fmt::{self, Display}; use std::borrow::Cow; -use ext::IntoOwned; -use parse::{Indexed, IndexedStr}; -use uri::{as_utf8_unchecked, Error, Segments}; +use crate::ext::IntoOwned; +use crate::parse::{Indexed, IndexedStr}; +use crate::uri::{as_utf8_unchecked, Error, Segments}; use state::Storage; @@ -63,7 +63,7 @@ use state::Storage; /// # } /// ``` /// -/// The [`Origin::to_normalized()`](uri::Origin::to_normalized()) method can be +/// The [`Origin::to_normalized()`](crate::uri::Origin::to_normalized()) method can be /// used to normalize any `Origin`: /// /// ```rust @@ -91,13 +91,13 @@ pub struct Origin<'a> { crate segment_count: Storage<usize>, } -impl<'a, 'b> PartialEq<Origin<'b>> for Origin<'a> { +impl<'b> PartialEq<Origin<'b>> for Origin<'_> { fn eq(&self, other: &Origin<'b>) -> bool { self.path() == other.path() && self.query() == other.query() } } -impl<'a> IntoOwned for Origin<'a> { +impl IntoOwned for Origin<'_> { type Owned = Origin<'static>; fn into_owned(self) -> Origin<'static> { @@ -166,7 +166,7 @@ impl<'a> Origin<'a> { /// Origin::parse("foo bar").expect_err("invalid URI"); /// ``` pub fn parse(string: &'a str) -> Result<Origin<'a>, Error<'a>> { - ::parse::uri::origin_from_str(string) + crate::parse::uri::origin_from_str(string) } // Parses an `Origin` that may contain `<` or `>` characters which are @@ -174,12 +174,12 @@ impl<'a> Origin<'a> { // this outside of Rocket! #[doc(hidden)] pub fn parse_route(string: &'a str) -> Result<Origin<'a>, Error<'a>> { - ::parse::uri::route_origin_from_str(string) + crate::parse::uri::route_origin_from_str(string) } /// Parses the string `string` into an `Origin`. Parsing will never /// allocate. This method should be used instead of - /// [`Origin::parse()`](uri::Origin::parse()) when the source URI is already + /// [`Origin::parse()`](crate::uri::Origin::parse()) when the source URI is already /// a `String`. Returns an `Error` if `string` is not a valid origin URI. /// /// # Example @@ -270,7 +270,7 @@ impl<'a> Origin<'a> { /// assert!(normalized.is_normalized()); /// assert_eq!(normalized, Origin::parse("/a/b/c/d").unwrap()); /// ``` - pub fn to_normalized(&self) -> Origin { + pub fn to_normalized(&self) -> Origin<'_> { if self.is_normalized() { Origin::new(self.path(), self.query()) } else { @@ -403,7 +403,7 @@ impl<'a> Origin<'a> { /// } /// ``` #[inline(always)] - pub fn segments(&self) -> Segments { + pub fn segments(&self) -> Segments<'_> { Segments(self.path()) } @@ -440,8 +440,8 @@ impl<'a> Origin<'a> { } } -impl<'a> Display for Origin<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl Display for Origin<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.path())?; if let Some(q) = self.query() { write!(f, "?{}", q)?; @@ -482,7 +482,7 @@ mod tests { #[test] fn send_and_sync() { fn assert<T: Send + Sync>() {}; - assert::<Origin>(); + assert::<Origin<'_>>(); } #[test] diff --git a/core/http/src/uri/segments.rs b/core/http/src/uri/segments.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use std::str::Utf8Error; -use uri::Uri; +use crate::uri::Uri; /// Iterator over the segments of an absolute URI path. Skips empty segments. /// @@ -40,7 +40,7 @@ pub enum SegmentError { BadEnd(char), } -impl<'a> Segments<'a> { +impl Segments<'_> { /// Creates a `PathBuf` from a `Segments` iterator. The returned `PathBuf` /// is percent-decoded. If a segment is equal to "..", the previous segment /// (if any) is skipped. diff --git a/core/http/src/uri/uri.rs b/core/http/src/uri/uri.rs @@ -4,10 +4,10 @@ use std::borrow::Cow; use std::str::Utf8Error; use std::convert::TryFrom; -use ext::IntoOwned; -use parse::Indexed; -use uri::{Origin, Authority, Absolute, Error}; -use uri::encoding::{percent_encode, DEFAULT_ENCODE_SET}; +use crate::ext::IntoOwned; +use crate::parse::Indexed; +use crate::uri::{Origin, Authority, Absolute, Error}; +use crate::uri::encoding::{percent_encode, DEFAULT_ENCODE_SET}; /// An `enum` encapsulating any of the possible URI variants. /// @@ -19,7 +19,7 @@ use uri::encoding::{percent_encode, DEFAULT_ENCODE_SET}; /// /// Nevertheless, the `Uri` type is typically enountered as a conversion target. /// In particular, you will likely see generic bounds of the form: `T: -/// TryInto<Uri>` (for instance, in [`Redirect`](::rocket::response::Redirect) +/// TryInto<Uri>` (for instance, in [`Redirect`](rocket::response::Redirect) /// methods). This means that you can provide any type `T` that implements /// `TryInto<Uri>`, or, equivalently, any type `U` for which `Uri` implements /// `TryFrom<U>` or `From<U>`. These include `&str` and `String`, [`Origin`], @@ -41,13 +41,13 @@ use uri::encoding::{percent_encode, DEFAULT_ENCODE_SET}; /// methods: [`Uri::percent_encode()`], [`Uri::percent_decode()`], and /// [`Uri::percent_decode_lossy()`]. /// -/// [`Origin`]: uri::Origin -/// [`Authority`]: uri::Authority -/// [`Absolute`]: uri::Absolute -/// [`Uri::parse()`]: uri::Uri::parse() -/// [`Uri::percent_encode()`]: uri::Uri::percent_encode() -/// [`Uri::percent_decode()`]: uri::Uri::percent_decode() -/// [`Uri::percent_decode_lossy()`]: uri::Uri::percent_decode_lossy() +/// [`Origin`]: crate::uri::Origin +/// [`Authority`]: crate::uri::Authority +/// [`Absolute`]: crate::uri::Absolute +/// [`Uri::parse()`]: crate::uri::Uri::parse() +/// [`Uri::percent_encode()`]: crate::uri::Uri::percent_encode() +/// [`Uri::percent_decode()`]: crate::uri::Uri::percent_decode() +/// [`Uri::percent_decode_lossy()`]: crate::uri::Uri::percent_decode_lossy() #[derive(Debug, PartialEq, Clone)] pub enum Uri<'a> { /// An origin URI. @@ -90,8 +90,8 @@ impl<'a> Uri<'a> { /// // Invalid URIs fail to parse. /// Uri::parse("foo bar").expect_err("invalid URI"); /// ``` - pub fn parse(string: &'a str) -> Result<Uri<'a>, Error> { - ::parse::uri::from_str(string) + pub fn parse(string: &'a str) -> Result<Uri<'a>, Error<'_>> { + crate::parse::uri::from_str(string) } /// Returns the internal instance of `Origin` if `self` is a `Uri::Origin`. @@ -172,7 +172,7 @@ impl<'a> Uri<'a> { /// let encoded = Uri::percent_encode("hello?a=<b>hi</b>"); /// assert_eq!(encoded, "hello%3Fa%3D%3Cb%3Ehi%3C%2Fb%3E"); /// ``` - pub fn percent_encode(string: &str) -> Cow<str> { + pub fn percent_encode(string: &str) -> Cow<'_, str> { percent_encode::<DEFAULT_ENCODE_SET>(string) } @@ -188,8 +188,8 @@ impl<'a> Uri<'a> { /// let decoded = Uri::percent_decode("/Hello%2C%20world%21".as_bytes()); /// assert_eq!(decoded.unwrap(), "/Hello, world!"); /// ``` - pub fn percent_decode(string: &[u8]) -> Result<Cow<str>, Utf8Error> { - let decoder = ::percent_encoding::percent_decode(string); + pub fn percent_decode(string: &[u8]) -> Result<Cow<'_, str>, Utf8Error> { + let decoder = percent_encoding::percent_decode(string); decoder.decode_utf8() } @@ -206,15 +206,15 @@ impl<'a> Uri<'a> { /// let decoded = Uri::percent_decode_lossy("/Hello%2C%20world%21".as_bytes()); /// assert_eq!(decoded, "/Hello, world!"); /// ``` - pub fn percent_decode_lossy(string: &[u8]) -> Cow<str> { - let decoder = ::percent_encoding::percent_decode(string); + pub fn percent_decode_lossy(string: &[u8]) -> Cow<'_, str> { + let decoder = percent_encoding::percent_decode(string); decoder.decode_utf8_lossy() } } -crate unsafe fn as_utf8_unchecked(input: Cow<[u8]>) -> Cow<str> { +crate unsafe fn as_utf8_unchecked(input: Cow<'_, [u8]>) -> Cow<'_, str> { match input { - Cow::Borrowed(bytes) => Cow::Borrowed(::std::str::from_utf8_unchecked(bytes)), + Cow::Borrowed(bytes) => Cow::Borrowed(std::str::from_utf8_unchecked(bytes)), Cow::Owned(bytes) => Cow::Owned(String::from_utf8_unchecked(bytes)) } } @@ -240,7 +240,7 @@ impl TryFrom<String> for Uri<'static> { } } -impl<'a> IntoOwned for Uri<'a> { +impl IntoOwned for Uri<'_> { type Owned = Uri<'static>; fn into_owned(self) -> Uri<'static> { @@ -253,8 +253,8 @@ impl<'a> IntoOwned for Uri<'a> { } } -impl<'a> Display for Uri<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl Display for Uri<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Uri::Origin(ref origin) => write!(f, "{}", origin), Uri::Authority(ref authority) => write!(f, "{}", authority), diff --git a/core/http/src/uri/uri_display.rs b/core/http/src/uri/uri_display.rs @@ -1,8 +1,8 @@ use std::{fmt, path}; use std::borrow::Cow; -use RawStr; -use uri::{Uri, UriPart, Path, Query, Formatter}; +use crate::RawStr; +use crate::uri::{Uri, UriPart, Path, Query, Formatter}; /// Trait implemented by types that can be displayed as part of a URI in /// [`uri!`]. @@ -44,9 +44,9 @@ use uri::{Uri, UriPart, Path, Query, Formatter}; /// # { fn fmt(&self, f: &mut Formatter<P>) -> fmt::Result { Ok(()) } } /// ``` /// -/// [`UriPart`]: uri::UriPart -/// [`Path`]: uri::Path -/// [`Query`]: uri::Query +/// [`UriPart`]: crate::uri::UriPart +/// [`Path`]: crate::uri::Path +/// [`Query`]: crate::uri::Query /// /// # Code Generation /// @@ -168,7 +168,7 @@ use uri::{Uri, UriPart, Path, Query, Formatter}; /// If the `Result` is `Ok`, uses the implementation of `UriDisplay` for /// `T`. Otherwise, nothing is rendered. /// -/// [`FromUriParam`]: uri::FromUriParam +/// [`FromUriParam`]: crate::uri::FromUriParam /// /// # Deriving /// @@ -204,15 +204,15 @@ use uri::{Uri, UriPart, Path, Query, Formatter}; /// [`Formatter::write_value()`] for every unnamed field. See the [`UriDisplay` /// derive] documentation for full details. /// -/// [`Ignorable`]: uri::Ignorable +/// [`Ignorable`]: crate::uri::Ignorable /// [`UriDisplay` derive]: ../../../rocket_codegen/derive.UriDisplay.html -/// [`Formatter::write_named_value()`]: uri::Formatter::write_named_value() -/// [`Formatter::write_value()`]: uri::Formatter::write_value() +/// [`Formatter::write_named_value()`]: crate::uri::Formatter::write_named_value() +/// [`Formatter::write_value()`]: crate::uri::Formatter::write_value() /// /// # Implementing /// /// Implementing `UriDisplay` is similar to implementing -/// [`Display`](::std::fmt::Display) with the caveat that extra care must be +/// [`Display`](std::fmt::Display) with the caveat that extra care must be /// taken to ensure that the written string is URI-safe. As mentioned before, in /// practice, this means that the string must either be percent-encoded or /// consist only of characters that are alphanumeric, "-", ".", "_", or "~". @@ -221,7 +221,7 @@ use uri::{Uri, UriPart, Path, Query, Formatter}; /// existing implementations of `UriDisplay` as much as possible. In the example /// below, for instance, `Name`'s implementation defers to `String`'s /// implementation. To percent-encode a string, use -/// [`Uri::percent_encode()`](uri::Uri::percent_encode()). +/// [`Uri::percent_encode()`](crate::uri::Uri::percent_encode()). /// /// ## Example /// @@ -291,13 +291,13 @@ use uri::{Uri, UriPart, Path, Query, Formatter}; /// ``` pub trait UriDisplay<P: UriPart> { /// Formats `self` in a URI-safe manner using the given formatter. - fn fmt(&self, f: &mut Formatter<P>) -> fmt::Result; + fn fmt(&self, f: &mut Formatter<'_, P>) -> fmt::Result; } -impl<'a, P: UriPart> fmt::Display for &'a UriDisplay<P> { +impl<P: UriPart> fmt::Display for &dyn UriDisplay<P> { #[inline(always)] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - UriDisplay::fmt(*self, &mut <Formatter<P>>::new(f)) + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + UriDisplay::fmt(*self, &mut <Formatter<'_, P>>::new(f)) } } @@ -306,14 +306,14 @@ impl<'a, P: UriPart> fmt::Display for &'a UriDisplay<P> { /// Percent-encodes the raw string. impl<P: UriPart> UriDisplay<P> for str { #[inline(always)] - fn fmt(&self, f: &mut Formatter<P>) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_, P>) -> fmt::Result { f.write_raw(&Uri::percent_encode(self)) } } /// Percent-encodes each segment in the path and normalizes separators. impl UriDisplay<Path> for path::Path { - fn fmt(&self, f: &mut Formatter<Path>) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_, Path>) -> fmt::Result { use std::path::Component; for component in self.components() { @@ -332,7 +332,7 @@ macro_rules! impl_with_display { /// This implementation is identical to the `Display` implementation. impl<P: UriPart> UriDisplay<P> for $T { #[inline(always)] - fn fmt(&self, f: &mut Formatter<P>) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_, P>) -> fmt::Result { use std::fmt::Write; write!(f, "{}", self) } @@ -355,7 +355,7 @@ impl_with_display! { /// Percent-encodes the raw string. Defers to `str`. impl<P: UriPart> UriDisplay<P> for RawStr { #[inline(always)] - fn fmt(&self, f: &mut Formatter<P>) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_, P>) -> fmt::Result { self.as_str().fmt(f) } } @@ -363,15 +363,15 @@ impl<P: UriPart> UriDisplay<P> for RawStr { /// Percent-encodes the raw string. Defers to `str`. impl<P: UriPart> UriDisplay<P> for String { #[inline(always)] - fn fmt(&self, f: &mut Formatter<P>) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_, P>) -> fmt::Result { self.as_str().fmt(f) } } /// Percent-encodes the raw string. Defers to `str`. -impl<'a, P: UriPart> UriDisplay<P> for Cow<'a, str> { +impl<P: UriPart> UriDisplay<P> for Cow<'_, str> { #[inline(always)] - fn fmt(&self, f: &mut Formatter<P>) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_, P>) -> fmt::Result { self.as_ref().fmt(f) } } @@ -379,23 +379,23 @@ impl<'a, P: UriPart> UriDisplay<P> for Cow<'a, str> { /// Percent-encodes each segment in the path and normalizes separators. impl UriDisplay<Path> for path::PathBuf { #[inline(always)] - fn fmt(&self, f: &mut Formatter<Path>) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_, Path>) -> fmt::Result { self.as_path().fmt(f) } } /// Defers to the `UriDisplay<P>` implementation for `T`. -impl<'a, P: UriPart, T: UriDisplay<P> + ?Sized> UriDisplay<P> for &'a T { +impl<P: UriPart, T: UriDisplay<P> + ?Sized> UriDisplay<P> for &T { #[inline(always)] - fn fmt(&self, f: &mut Formatter<P>) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_, P>) -> fmt::Result { UriDisplay::fmt(*self, f) } } /// Defers to the `UriDisplay<P>` implementation for `T`. -impl<'a, P: UriPart, T: UriDisplay<P> + ?Sized> UriDisplay<P> for &'a mut T { +impl<P: UriPart, T: UriDisplay<P> + ?Sized> UriDisplay<P> for &mut T { #[inline(always)] - fn fmt(&self, f: &mut Formatter<P>) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_, P>) -> fmt::Result { UriDisplay::fmt(*self, f) } } @@ -403,7 +403,7 @@ impl<'a, P: UriPart, T: UriDisplay<P> + ?Sized> UriDisplay<P> for &'a mut T { /// Defers to the `UriDisplay<Query>` implementation for `T`. impl<T: UriDisplay<Query>> UriDisplay<Query> for Option<T> { #[inline(always)] - fn fmt(&self, f: &mut Formatter<Query>) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_, Query>) -> fmt::Result { match self { Some(v) => v.fmt(f), None => Ok(()) @@ -414,7 +414,7 @@ impl<T: UriDisplay<Query>> UriDisplay<Query> for Option<T> { /// Defers to the `UriDisplay<Query>` implementation for `T`. impl<T: UriDisplay<Query>, E> UriDisplay<Query> for Result<T, E> { #[inline(always)] - fn fmt(&self, f: &mut Formatter<Query>) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_, Query>) -> fmt::Result { match self { Ok(v) => v.fmt(f), Err(_) => Ok(()) @@ -469,7 +469,7 @@ pub fn assert_ignorable<P: UriPart, T: Ignorable<P>>() { } #[cfg(test)] mod uri_display_tests { use std::path; - use uri::{FromUriParam, UriDisplay, Query, Path}; + use crate::uri::{FromUriParam, UriDisplay, Query, Path}; macro_rules! uri_display { (<$P:ident, $Target:ty> $source:expr) => ({ @@ -577,7 +577,7 @@ mod uri_display_tests { #[test] fn check_ignorables() { - use uri::assert_ignorable; + use crate::uri::assert_ignorable; assert_ignorable::<Query, Option<usize>>(); assert_ignorable::<Query, Option<Wrapper<usize>>>();