Remove all extern crate...

In Rust 2018 edition, it is considered unidiomatic to use "extern crate"
sunthax. The proper way to do it is to replace extern crate with "use"
declarations.

- Also impl clippy suggestions for fn main removal in doctests
- Fix unneeded box allocations and clones

Signed-off-by: Damien Stanton <damien.stanton@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
This commit is contained in:
Damien Stanton
2020-07-28 11:55:14 -04:00
committed by Adrian Catangiu
parent a7f035b8c5
commit eeae4ac11d
6 changed files with 2 additions and 15 deletions

View File

@@ -117,7 +117,6 @@ impl Headers {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// extern crate micro_http;
/// use micro_http::Headers; /// use micro_http::Headers;
/// ///
/// let mut request_header = Headers::default(); /// let mut request_header = Headers::default();
@@ -217,7 +216,6 @@ impl Headers {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// extern crate micro_http;
/// use micro_http::Headers; /// use micro_http::Headers;
/// ///
/// let request_headers = Headers::try_from(b"Content-Length: 55\r\n\r\n"); /// let request_headers = Headers::try_from(b"Content-Length: 55\r\n\r\n");
@@ -275,7 +273,6 @@ impl MediaType {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// extern crate micro_http;
/// use micro_http::MediaType; /// use micro_http::MediaType;
/// ///
/// assert!(MediaType::try_from(b"application/json").is_ok()); /// assert!(MediaType::try_from(b"application/json").is_ok());
@@ -299,7 +296,6 @@ impl MediaType {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// extern crate micro_http;
/// use micro_http::MediaType; /// use micro_http::MediaType;
/// ///
/// let media_type = MediaType::ApplicationJson; /// let media_type = MediaType::ApplicationJson;

View File

@@ -131,7 +131,6 @@ impl Display for ServerError {
/// ///
/// ## Examples /// ## Examples
/// ``` /// ```
/// extern crate micro_http;
/// use micro_http::Body; /// use micro_http::Body;
/// let body = Body::new("This is a test body.".to_string()); /// let body = Body::new("This is a test body.".to_string());
/// assert_eq!(body.raw(), b"This is a test body."); /// assert_eq!(body.raw(), b"This is a test body.");
@@ -216,7 +215,6 @@ impl Method {
/// ///
/// # Examples /// # Examples
/// ``` /// ```
/// extern crate micro_http;
/// use micro_http::Version; /// use micro_http::Version;
/// let version = Version::try_from(b"HTTP/1.1"); /// let version = Version::try_from(b"HTTP/1.1");
/// assert!(version.is_ok()); /// assert!(version.is_ok());

View File

@@ -45,7 +45,6 @@
//! //!
//! ## Example for parsing an HTTP Request from a slice //! ## Example for parsing an HTTP Request from a slice
//! ``` //! ```
//! extern crate micro_http;
//! use micro_http::{Request, Version}; //! use micro_http::{Request, Version};
//! //!
//! let http_request = Request::try_from(b"GET http://localhost/home HTTP/1.0\r\n\r\n").unwrap(); //! let http_request = Request::try_from(b"GET http://localhost/home HTTP/1.0\r\n\r\n").unwrap();
@@ -55,7 +54,6 @@
//! //!
//! ## Example for creating an HTTP Response //! ## Example for creating an HTTP Response
//! ``` //! ```
//! extern crate micro_http;
//! use micro_http::{Body, MediaType, Response, StatusCode, Version}; //! use micro_http::{Body, MediaType, Response, StatusCode, Version};
//! //!
//! let mut response = Response::new(Version::Http10, StatusCode::OK); //! let mut response = Response::new(Version::Http10, StatusCode::OK);
@@ -82,7 +80,6 @@
//! ## Example for using the server //! ## Example for using the server
//! //!
//! ``` //! ```
//! extern crate micro_http;
//! use micro_http::{HttpServer, Response, StatusCode}; //! use micro_http::{HttpServer, Response, StatusCode};
//! //!
//! let path_to_socket = "/tmp/example.sock"; //! let path_to_socket = "/tmp/example.sock";
@@ -109,9 +106,6 @@
//! } //! }
//! ``` //! ```
extern crate libc;
extern crate utils;
mod common; mod common;
mod connection; mod connection;
mod request; mod request;

View File

@@ -178,7 +178,6 @@ impl Request {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// extern crate micro_http;
/// use micro_http::Request; /// use micro_http::Request;
/// ///
/// let http_request = Request::try_from(b"GET http://localhost/home HTTP/1.0\r\n\r\n").unwrap(); /// let http_request = Request::try_from(b"GET http://localhost/home HTTP/1.0\r\n\r\n").unwrap();

View File

@@ -397,8 +397,6 @@ impl HttpServer {
/// ///
/// ## Non-blocking server /// ## Non-blocking server
/// ``` /// ```
/// extern crate utils;
///
/// use std::os::unix::io::AsRawFd; /// use std::os::unix::io::AsRawFd;
/// ///
/// use micro_http::{HttpServer, Response, StatusCode}; /// use micro_http::{HttpServer, Response, StatusCode};

View File

@@ -1,6 +1,8 @@
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
use serde::{export::Formatter, Deserialize};
use std::fmt::{Display, Result};
use std::net::Ipv4Addr; use std::net::Ipv4Addr;
/// Keeps the MMDS configuration. /// Keeps the MMDS configuration.