Switch to 2021 edition (#172)

This commit is contained in:
Nikolay Kim 2023-02-03 00:30:07 +06:00 committed by GitHub
parent 0c61a78d60
commit 29e04cf478
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 54 additions and 81 deletions

View file

@ -9,7 +9,7 @@ repository = "https://github.com/ntex-rs/ntex.git"
documentation = "https://docs.rs/ntex-rt-async-std/"
categories = ["network-programming", "asynchronous"]
license = "MIT"
edition = "2018"
edition = "2021"
[lib]
name = "ntex_async_std"

View file

@ -9,7 +9,7 @@ repository = "https://github.com/ntex-rs"
readme = "README.md"
keywords = ["buffers", "zero-copy", "io"]
categories = ["network-programming", "data-structures"]
edition = "2018"
edition = "2021"
[features]
default = []

View file

@ -1,5 +1,4 @@
use std::borrow::{Borrow, BorrowMut};
use std::iter::{FromIterator, Iterator};
use std::ops::{Deref, DerefMut, RangeBounds};
use std::sync::atomic::Ordering::{Acquire, Relaxed, Release};
use std::sync::atomic::{self, AtomicUsize};
@ -4049,7 +4048,7 @@ fn abort() {
#[cfg(test)]
mod tests {
use std::{collections::HashMap, convert::TryFrom};
use std::collections::HashMap;
use super::*;

View file

@ -1,5 +1,5 @@
//! A UTF-8 encoded read-only string using Bytes as storage.
use std::{borrow, convert::TryFrom, fmt, hash, ops, slice, str};
use std::{borrow, fmt, hash, ops, slice, str};
use crate::{Bytes, BytesMut, BytesVec};

View file

@ -96,7 +96,6 @@ fn fmt() {
#[test]
fn fmt_write() {
use std::fmt::Write;
use std::iter::FromIterator;
let s = String::from_iter((0..10).map(|_| "abcdefg"));
let mut a = BytesMut::with_capacity(64);

View file

@ -9,7 +9,7 @@ repository = "https://github.com/ntex-rs/ntex.git"
documentation = "https://docs.rs/ntex-codec/"
categories = ["network-programming", "asynchronous"]
license = "MIT"
edition = "2018"
edition = "2021"
[lib]
name = "ntex_codec"

View file

@ -9,7 +9,7 @@ repository = "https://github.com/ntex-rs/ntex.git"
documentation = "https://docs.rs/ntex-connect/"
categories = ["network-programming", "asynchronous"]
license = "MIT"
edition = "2018"
edition = "2021"
[lib]
name = "ntex_connect"

View file

@ -1,5 +1,5 @@
use std::collections::{vec_deque, VecDeque};
use std::{fmt, iter::FromIterator, iter::FusedIterator, net::SocketAddr};
use std::{fmt, iter::FusedIterator, net::SocketAddr};
use ntex_util::future::Either;

View file

@ -1,4 +1,4 @@
use std::{convert::TryFrom, io};
use std::io;
pub use ntex_tls::rustls::TlsFilter;
pub use tls_rustls::{ClientConfig, ServerName};

View file

@ -9,7 +9,7 @@ repository = "https://github.com/ntex-rs/ntex.git"
documentation = "https://docs.rs/ntex-rt-glommio/"
categories = ["network-programming", "asynchronous"]
license = "MIT"
edition = "2018"
edition = "2021"
[lib]
name = "ntex_glommio"

View file

@ -9,7 +9,7 @@ repository = "https://github.com/ntex-rs/ntex.git"
documentation = "https://docs.rs/ntex-http/"
categories = ["network-programming", "asynchronous"]
license = "MIT"
edition = "2018"
edition = "2021"
[lib]
name = "ntex_http"

View file

@ -1,5 +1,4 @@
use std::collections::{self, hash_map, hash_map::Entry, VecDeque};
use std::{convert::TryFrom, iter::FromIterator};
use crate::{HeaderName, HeaderValue};

View file

@ -4,7 +4,7 @@
clippy::no_effect,
clippy::missing_safety_doc
)]
use std::{cmp, convert::TryFrom, error::Error, fmt, str, str::FromStr};
use std::{cmp, error::Error, fmt, str, str::FromStr};
use ntex_bytes::{ByteString, Bytes};

View file

@ -9,7 +9,7 @@ repository = "https://github.com/ntex-rs/ntex.git"
documentation = "https://docs.rs/ntex-io/"
categories = ["network-programming", "asynchronous"]
license = "MIT"
edition = "2018"
edition = "2021"
[lib]
name = "ntex_io"

View file

@ -732,14 +732,12 @@ mod tests {
ntex_util::services::inflight::InFlightService::new(
1,
ntex_service::fn_service(move |msg: DispatchItem<BytesCodec>| async move {
match msg {
DispatchItem::Item(_) => {
if let DispatchItem::Item(_) = msg {
sleep(Millis(500)).await;
return Ok::<_, ()>(None);
}
_ => (),
}
Ok::<_, ()>(None)
} else {
Ok(None)
}
}),
),
);

View file

@ -136,7 +136,7 @@ mod tests {
type Future = Ready<Io<Layer<TestFilter, F>>, Self::Error>;
fn create(self, st: Io<F>) -> Self::Future {
Ready::Ok(st.add_filter(TestFilter).into())
Ready::Ok(st.add_filter(TestFilter))
}
}
@ -163,12 +163,9 @@ mod tests {
let (_, server) = IoTest::create();
let io = Io::new(server);
let ioref = io.get_ref();
let mut stack = Stack::new();
let stack = Stack::new();
assert!(NullFilter.query(std::any::TypeId::of::<()>()).is_none());
assert!(NullFilter
.shutdown(&ioref, &mut stack, 0)
.unwrap()
.is_ready());
assert!(NullFilter.shutdown(&ioref, &stack, 0).unwrap().is_ready());
assert_eq!(
ntex_util::future::poll_fn(|cx| NullFilter.poll_read_ready(cx)).await,
crate::ReadStatus::Terminate
@ -177,11 +174,9 @@ mod tests {
ntex_util::future::poll_fn(|cx| NullFilter.poll_write_ready(cx)).await,
crate::WriteStatus::Terminate
);
assert!(NullFilter.process_write_buf(&ioref, &mut stack, 0).is_ok());
assert!(NullFilter.process_write_buf(&ioref, &stack, 0).is_ok());
assert_eq!(
NullFilter
.process_read_buf(&ioref, &mut stack, 0, 0)
.unwrap(),
NullFilter.process_read_buf(&ioref, &stack, 0, 0).unwrap(),
Default::default()
)
}

View file

@ -5,7 +5,7 @@ description = "ntex proc macros"
readme = "README.md"
authors = ["ntex contributors <team@ntex.rs>"]
license = "MIT"
edition = "2018"
edition = "2021"
[lib]
proc-macro = true

View file

@ -7,7 +7,7 @@ keywords = ["ntex"]
repository = "https://github.com/ntex-rs/ntex.git"
documentation = "https://docs.rs/ntex-router/"
license = "MIT"
edition = "2018"
edition = "2021"
[lib]
name = "ntex_router"

View file

@ -638,7 +638,6 @@ mod tests {
#[test]
fn test_parse_urlencoded() {
use http::Uri;
use std::convert::TryFrom;
let tree = Tree::new(&ResourceDef::new("/user/{id}/test"), 1);
let uri = Uri::try_from("/user/2345/test").unwrap();
@ -677,7 +676,6 @@ mod tests {
#[test]
fn test_extract_path_decode() {
use http::Uri;
use std::convert::TryFrom;
let tree = Tree::new(&ResourceDef::new("/{id}/"), 1);

View file

@ -9,7 +9,7 @@ repository = "https://github.com/ntex-rs/ntex.git"
documentation = "https://docs.rs/ntex-rt/"
categories = ["network-programming", "asynchronous"]
license = "MIT"
edition = "2018"
edition = "2021"
[lib]
name = "ntex_rt"

View file

@ -9,7 +9,7 @@ repository = "https://github.com/ntex-rs/ntex.git"
documentation = "https://docs.rs/ntex-service/"
categories = ["network-programming", "asynchronous"]
license = "MIT"
edition = "2018"
edition = "2021"
[lib]
name = "ntex_service"

View file

@ -9,7 +9,7 @@ repository = "https://github.com/ntex-rs/ntex.git"
documentation = "https://docs.rs/ntex-openssl/"
categories = ["network-programming", "asynchronous"]
license = "MIT"
edition = "2018"
edition = "2021"
[lib]
name = "ntex_tls"

View file

@ -9,7 +9,7 @@ repository = "https://github.com/ntex-rs/ntex.git"
documentation = "https://docs.rs/ntex-rt-tokio/"
categories = ["network-programming", "asynchronous"]
license = "MIT"
edition = "2018"
edition = "2021"
[lib]
name = "ntex_tokio"

View file

@ -9,7 +9,7 @@ repository = "https://github.com/ntex-rs/ntex.git"
documentation = "https://docs.rs/ntex-util/"
categories = ["network-programming", "asynchronous"]
license = "MIT"
edition = "2018"
edition = "2021"
[lib]
name = "ntex_util"

View file

@ -1,8 +1,5 @@
use std::task::{Context, Poll};
use std::{
cell::Cell, convert::Infallible, convert::TryInto, marker, time::Duration,
time::Instant,
};
use std::{cell::Cell, convert::Infallible, marker, time::Duration, time::Instant};
use ntex_service::{Service, ServiceFactory};

View file

@ -1,4 +1,4 @@
use std::{convert::TryInto, ops};
use std::ops;
/// A Duration type to represent a span of time.
///

View file

@ -11,7 +11,7 @@ categories = ["network-programming", "asynchronous",
"web-programming::http-server",
"web-programming::websocket"]
license = "MIT"
edition = "2018"
edition = "2021"
[package.metadata.docs.rs]
features = ["tokio", "openssl", "rustls", "compress", "cookie"]

View file

@ -1,4 +1,4 @@
use std::{convert::TryFrom, fmt, rc::Rc};
use std::{fmt, rc::Rc};
use base64::{engine::general_purpose::STANDARD as base64, Engine};

View file

@ -1,4 +1,4 @@
use std::{convert::TryFrom, error::Error, fmt, net, rc::Rc};
use std::{error::Error, fmt, net, rc::Rc};
use crate::http::body::Body;
use crate::http::error::HttpError;

View file

@ -1,4 +1,4 @@
use std::{cell::RefCell, convert::TryFrom, io, rc::Rc};
use std::{cell::RefCell, io, rc::Rc};
use ntex_h2::{self as h2, client::Client, frame};

View file

@ -16,7 +16,7 @@
//! println!("Response: {:?}", response);
//! }
//! ```
use std::{convert::TryFrom, rc::Rc};
use std::rc::Rc;
mod builder;
mod connect;

View file

@ -617,7 +617,7 @@ impl Drop for Acquired {
#[cfg(test)]
mod tests {
use std::{cell::RefCell, convert::TryFrom, rc::Rc};
use std::{cell::RefCell, rc::Rc};
use super::*;
use crate::{

View file

@ -1,4 +1,4 @@
use std::{convert::TryFrom, error::Error, fmt, net, rc::Rc};
use std::{error::Error, fmt, net, rc::Rc};
use base64::{engine::general_purpose::STANDARD as base64, Engine};
#[cfg(feature = "cookie")]

View file

@ -1,5 +1,5 @@
use std::task::{Context, Poll};
use std::{convert::TryFrom, error::Error, future::Future, net, pin::Pin, rc::Rc};
use std::{error::Error, future::Future, net, pin::Pin, rc::Rc};
use serde::Serialize;

View file

@ -1,6 +1,4 @@
//! Test helpers for ntex http client to use during testing.
use std::convert::TryFrom;
#[cfg(feature = "cookie")]
use coo_kie::{Cookie, CookieJar};

View file

@ -1,4 +1,4 @@
use std::{cell::Cell, convert::TryFrom, marker::PhantomData, mem, task::Poll};
use std::{cell::Cell, marker::PhantomData, mem, task::Poll};
use ntex_http::header::{HeaderName, HeaderValue};
use ntex_http::{header, Method, StatusCode, Uri, Version};

View file

@ -1,5 +1,5 @@
use std::{cell::RefCell, io, task::Context, task::Poll};
use std::{convert::TryFrom, marker::PhantomData, mem, rc::Rc};
use std::{marker::PhantomData, mem, rc::Rc};
use ntex_h2::{self as h2, frame::StreamId, server};

View file

@ -205,7 +205,6 @@ impl fmt::Debug for Request {
#[cfg(test)]
mod tests {
use super::*;
use std::convert::TryFrom;
#[test]
fn test_basics() {

View file

@ -1,5 +1,5 @@
//! Http response
use std::{cell::Ref, cell::RefMut, convert::TryFrom, error::Error, fmt, str};
use std::{cell::Ref, cell::RefMut, error::Error, fmt, str};
use serde::Serialize;

View file

@ -1,5 +1,5 @@
//! Test helpers to use during testing.
use std::{convert::TryFrom, net, str::FromStr, sync::mpsc, thread};
use std::{net, str::FromStr, sync::mpsc, thread};
#[cfg(feature = "cookie")]
use coo_kie::{Cookie, CookieJar};

View file

@ -1,4 +1,4 @@
use std::{convert::TryInto, net::SocketAddr, rc::Rc, task::Context, task::Poll};
use std::{net::SocketAddr, rc::Rc, task::Context, task::Poll};
use log::error;

View file

@ -1,4 +1,4 @@
use std::{convert::TryFrom, fmt, io, net};
use std::{fmt, io, net};
use crate::{io::Io, rt};

View file

@ -595,8 +595,8 @@ mod tests {
use crate::util::{Bytes, Ready};
use crate::web::test::{call_service, init_service, read_body, TestRequest};
use crate::web::{
self, middleware::DefaultHeaders, request::WebRequest, DefaultError, HttpRequest,
HttpResponse,
self, middleware::DefaultHeaders, DefaultError, HttpRequest, HttpResponse,
WebRequest,
};
#[crate::rt_test]

View file

@ -26,7 +26,6 @@
//! }
//! ```
#![allow(non_snake_case)]
use std::convert::TryFrom;
use crate::http::{header, Method, RequestHead, Uri};

View file

@ -336,7 +336,7 @@ mod tests {
use super::*;
use crate::http::{header, StatusCode};
use crate::router::ResourceDef;
use crate::web::dev::ResourceMap;
use crate::web::test::{call_service, init_service, TestRequest};
use crate::web::{self, App, HttpResponse};

View file

@ -1,5 +1,5 @@
//! Middleware for setting default response headers
use std::{convert::TryFrom, rc::Rc};
use std::rc::Rc;
use crate::http::error::HttpError;
use crate::http::header::{HeaderMap, HeaderName, HeaderValue, CONTENT_TYPE};

View file

@ -1,6 +1,6 @@
//! Request logging middleware
use std::task::{Context, Poll};
use std::{convert::TryFrom, env, error::Error, future::Future, pin::Pin, rc::Rc, time};
use std::{env, error::Error, future::Future, pin::Pin, rc::Rc, time};
use std::{fmt, fmt::Display, marker::PhantomData};
use regex::Regex;

View file

@ -1,5 +1,5 @@
use std::task::{Context, Poll};
use std::{convert::TryFrom, future::Future, marker::PhantomData, pin::Pin};
use std::{future::Future, marker::PhantomData, pin::Pin};
use crate::http::error::HttpError;
use crate::http::header::{HeaderMap, HeaderName, HeaderValue};

View file

@ -1,7 +1,5 @@
//! Various helpers for ntex applications to use during testing.
use std::{
convert::TryFrom, error::Error, fmt, net, net::SocketAddr, rc::Rc, sync::mpsc, thread,
};
use std::{error::Error, fmt, net, net::SocketAddr, rc::Rc, sync::mpsc, thread};
#[cfg(feature = "cookie")]
use coo_kie::Cookie;

View file

@ -1,5 +1,5 @@
//! Websockets client
use std::{cell::RefCell, convert::TryFrom, fmt, marker, net, rc::Rc, str};
use std::{cell::RefCell, fmt, marker, net, rc::Rc, str};
#[cfg(feature = "openssl")]
use crate::connect::openssl;

View file

@ -1,5 +1,3 @@
use std::convert::TryFrom;
use log::debug;
use nanorand::{Rng, WyRand};

View file

@ -256,8 +256,6 @@ async fn test_create() {
#[cfg(feature = "openssl")]
#[ntex::test]
async fn test_uri() {
use std::convert::TryFrom;
let srv = test_server(|| {
fn_service(|io: Io| async move {
io.send(Bytes::from_static(b"test"), &BytesCodec)
@ -278,8 +276,6 @@ async fn test_uri() {
#[cfg(feature = "rustls")]
#[ntex::test]
async fn test_rustls_uri() {
use std::convert::TryFrom;
let srv = test_server(|| {
fn_service(|io: Io| async move {
io.send(Bytes::from_static(b"test"), &BytesCodec)

View file

@ -119,7 +119,7 @@ async fn test_run() {
assert_eq!(buf, b"test"[..]);
// stop
let _ = srv.stop(false).await;
srv.stop(false).await;
thread::sleep(time::Duration::from_millis(100));
assert!(net::TcpStream::connect(addr).is_err());