Skip to content

Commit 77664ab

Browse files
committed
Make imports consistent.
1 parent 9fbabab commit 77664ab

34 files changed

+187
-142
lines changed

examples/chat.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ use std::collections::HashSet;
1010
use std::net::SocketAddr;
1111
use std::sync::{Arc, Mutex};
1212

13-
use futures::{sink::SinkExt, stream::StreamExt};
14-
15-
use tokio::sync::broadcast;
16-
1713
use axum::prelude::*;
1814
use axum::response::Html;
1915
use axum::ws::{ws, Message, WebSocket};
2016
use axum::AddExtensionLayer;
17+
use futures::{sink::SinkExt, stream::StreamExt};
18+
use tokio::sync::broadcast;
2119

2220
// Our shared state
2321
struct AppState {

examples/error_handling_and_dependency_injection.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
1010
#![allow(dead_code)]
1111

12+
use std::{net::SocketAddr, sync::Arc};
13+
1214
use axum::{
1315
async_trait,
1416
extract::{Extension, Json, UrlParams},
@@ -19,7 +21,6 @@ use axum::{
1921
use http::StatusCode;
2022
use serde::{Deserialize, Serialize};
2123
use serde_json::json;
22-
use std::{net::SocketAddr, sync::Arc};
2324
use uuid::Uuid;
2425

2526
#[tokio::main]

examples/form.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
//! cargo run --example form
55
//! ```
66
7+
use std::net::SocketAddr;
8+
79
use axum::prelude::*;
810
use serde::Deserialize;
9-
use std::net::SocketAddr;
1011

1112
#[tokio::main]
1213
async fn main() {

examples/hello_world.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
//! cargo run --example hello_world
55
//! ```
66
7-
use axum::prelude::*;
87
use std::net::SocketAddr;
98

9+
use axum::prelude::*;
10+
1011
#[tokio::main]
1112
async fn main() {
1213
tracing_subscriber::fmt::init();

examples/key_value_store.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
//! cargo run --example key_value_store
77
//! ```
88
9+
use std::{
10+
borrow::Cow,
11+
collections::HashMap,
12+
convert::Infallible,
13+
net::SocketAddr,
14+
sync::{Arc, RwLock},
15+
time::Duration,
16+
};
17+
918
use axum::{
1019
async_trait,
1120
extract::{extractor_middleware, ContentLengthLimit, Extension, RequestParts, UrlParams},
@@ -16,14 +25,6 @@ use axum::{
1625
};
1726
use bytes::Bytes;
1827
use http::StatusCode;
19-
use std::{
20-
borrow::Cow,
21-
collections::HashMap,
22-
convert::Infallible,
23-
net::SocketAddr,
24-
sync::{Arc, RwLock},
25-
time::Duration,
26-
};
2728
use tower::{BoxError, ServiceBuilder};
2829
use tower_http::{
2930
add_extension::AddExtensionLayer, compression::CompressionLayer, trace::TraceLayer,

examples/multipart_form.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
//! cargo run --example multipart_form --features=multipart
55
//! ```
66
7+
use std::net::SocketAddr;
8+
79
use axum::{
810
extract::{ContentLengthLimit, Multipart},
911
prelude::*,
1012
};
11-
use std::net::SocketAddr;
1213

1314
#[tokio::main]
1415
async fn main() {

examples/sessions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//! cargo run --example sessions
55
//! ```
66
7+
use std::net::SocketAddr;
8+
79
use async_session::{MemoryStore, Session, SessionStore as _};
810
use axum::{
911
async_trait,
@@ -15,7 +17,6 @@ use axum::{
1517
use http::header::{HeaderMap, HeaderValue};
1618
use http::StatusCode;
1719
use serde::{Deserialize, Serialize};
18-
use std::net::SocketAddr;
1920
use uuid::Uuid;
2021

2122
#[tokio::main]

examples/sse.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
//! cargo run --example sse --features=headers
55
//! ```
66
7+
use std::{convert::Infallible, net::SocketAddr, time::Duration};
8+
79
use axum::{extract::TypedHeader, prelude::*, routing::nest, service::ServiceExt, sse::Event};
810
use futures::stream::{self, Stream};
911
use http::StatusCode;
10-
use std::{convert::Infallible, net::SocketAddr, time::Duration};
1112
use tokio_stream::StreamExt as _;
1213
use tower_http::{services::ServeDir, trace::TraceLayer};
1314

examples/static_file_server.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
//! cargo run --example static_file_server
55
//! ```
66
7+
use std::net::SocketAddr;
8+
79
use axum::{prelude::*, routing::nest, service::ServiceExt};
810
use http::StatusCode;
9-
use std::net::SocketAddr;
1011
use tower_http::{services::ServeDir, trace::TraceLayer};
1112

1213
#[tokio::main]

examples/templates.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
//! cargo run --example templates
55
//! ```
66
7+
use std::net::SocketAddr;
8+
79
use askama::Template;
810
use axum::{prelude::*, response::IntoResponse};
911
use http::{Response, StatusCode};
10-
use std::net::SocketAddr;
1112

1213
#[tokio::main]
1314
async fn main() {

examples/tls_rustls.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
//! cargo run --example tls_rustls
55
//! ```
66
7+
use std::{fs::File, io::BufReader, sync::Arc};
8+
79
use axum::prelude::*;
810
use hyper::server::conn::Http;
9-
use std::{fs::File, io::BufReader, sync::Arc};
1011
use tokio::net::TcpListener;
1112
use tokio_rustls::{
1213
rustls::{

examples/todos.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
//! cargo run --example todos
1414
//! ```
1515
16+
use std::{
17+
collections::HashMap,
18+
convert::Infallible,
19+
net::SocketAddr,
20+
sync::{Arc, RwLock},
21+
time::Duration,
22+
};
23+
1624
use axum::{
1725
extract::{Extension, Json, Query, UrlParams},
1826
prelude::*,
@@ -21,13 +29,6 @@ use axum::{
2129
};
2230
use http::StatusCode;
2331
use serde::{Deserialize, Serialize};
24-
use std::{
25-
collections::HashMap,
26-
convert::Infallible,
27-
net::SocketAddr,
28-
sync::{Arc, RwLock},
29-
time::Duration,
30-
};
3132
use tower::{BoxError, ServiceBuilder};
3233
use tower_http::{add_extension::AddExtensionLayer, trace::TraceLayer};
3334
use uuid::Uuid;

examples/tokio_postgres.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
//! cargo run --example tokio_postgres
55
//! ```
66
7+
use std::net::SocketAddr;
8+
79
use axum::{extract::Extension, prelude::*, AddExtensionLayer};
810
use bb8::Pool;
911
use bb8_postgres::PostgresConnectionManager;
1012
use http::StatusCode;
11-
use std::net::SocketAddr;
1213
use tokio_postgres::NoTls;
1314

1415
#[tokio::main]

examples/unix_domain_socket.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
//! cargo run --example unix_domain_socket
55
//! ```
66
7+
use std::{
8+
io,
9+
path::PathBuf,
10+
pin::Pin,
11+
sync::Arc,
12+
task::{Context, Poll},
13+
};
14+
715
use axum::{
816
extract::connect_info::{self, ConnectInfo},
917
prelude::*,
@@ -14,13 +22,6 @@ use hyper::{
1422
client::connect::{Connected, Connection},
1523
server::accept::Accept,
1624
};
17-
use std::{
18-
io,
19-
path::PathBuf,
20-
pin::Pin,
21-
sync::Arc,
22-
task::{Context, Poll},
23-
};
2425
use tokio::net::{unix::UCred, UnixListener};
2526
use tokio::{
2627
io::{AsyncRead, AsyncWrite},

examples/versioning.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//! cargo run --example versioning
55
//! ```
66
7+
use std::net::SocketAddr;
8+
79
use axum::response::IntoResponse;
810
use axum::{
911
async_trait,
@@ -12,7 +14,6 @@ use axum::{
1214
};
1315
use http::Response;
1416
use http::StatusCode;
15-
use std::net::SocketAddr;
1617

1718
#[tokio::main]
1819
async fn main() {

examples/websocket.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//! RUST_LOG=tower_http=debug,key_value_store=trace cargo run --features=ws,headers --example websocket
77
//! ```
88
9+
use std::net::SocketAddr;
10+
911
use axum::{
1012
extract::TypedHeader,
1113
prelude::*,
@@ -14,7 +16,6 @@ use axum::{
1416
ws::{ws, Message, WebSocket},
1517
};
1618
use http::StatusCode;
17-
use std::net::SocketAddr;
1819
use tower_http::{
1920
services::ServeDir,
2021
trace::{DefaultMakeSpan, TraceLayer},

src/body.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//! HTTP body utilities.
22
3+
use std::{error::Error as StdError, fmt};
4+
35
use bytes::Bytes;
46
use http_body::Body as _;
5-
use std::{error::Error as StdError, fmt};
67
use tower::BoxError;
78

89
pub use hyper::body::Body;

src/buffer.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
use futures_util::ready;
2-
use pin_project::pin_project;
31
use std::{
42
future::Future,
53
pin::Pin,
64
sync::Arc,
75
task::{Context, Poll},
86
};
7+
8+
use futures_util::ready;
9+
use pin_project::pin_project;
910
use tokio::sync::{mpsc, oneshot, OwnedSemaphorePermit, Semaphore};
1011
use tokio_util::sync::PollSemaphore;
1112
use tower::{Service, ServiceExt};

src/extract/connect_info.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44
//!
55
//! [`RoutingDsl::into_make_service_with_connect_info`]: crate::routing::RoutingDsl::into_make_service_with_connect_info
66
7-
use super::{Extension, FromRequest, RequestParts};
8-
use async_trait::async_trait;
9-
use hyper::server::conn::AddrStream;
107
use std::{
118
convert::Infallible,
129
fmt,
1310
marker::PhantomData,
1411
net::SocketAddr,
1512
task::{Context, Poll},
1613
};
14+
15+
use async_trait::async_trait;
16+
use hyper::server::conn::AddrStream;
1717
use tower::Service;
1818
use tower_http::add_extension::AddExtension;
1919

20+
use super::{Extension, FromRequest, RequestParts};
21+
2022
/// A [`MakeService`] created from a router.
2123
///
2224
/// See [`RoutingDsl::into_make_service_with_connect_info`] for more details.

src/extract/extractor_middleware.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
//!
33
//! See [`extractor_middleware`] for more details.
44
5-
use super::{FromRequest, RequestParts};
6-
use crate::{body::BoxBody, response::IntoResponse};
7-
use bytes::Bytes;
8-
use futures_util::{future::BoxFuture, ready};
9-
use http::{Request, Response};
10-
use pin_project::pin_project;
115
use std::{
126
fmt,
137
future::Future,
148
marker::PhantomData,
159
pin::Pin,
1610
task::{Context, Poll},
1711
};
12+
13+
use bytes::Bytes;
14+
use futures_util::{future::BoxFuture, ready};
15+
use http::{Request, Response};
16+
use pin_project::pin_project;
1817
use tower::{BoxError, Layer, Service};
1918

19+
use super::{FromRequest, RequestParts};
20+
use crate::{body::BoxBody, response::IntoResponse};
21+
2022
/// Convert an extractor into a middleware.
2123
///
2224
/// If the extractor succeeds the value will be discarded and the inner service

src/extract/mod.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,6 @@
244244
//!
245245
//! [`body::Body`]: crate::body::Body
246246
247-
use crate::{response::IntoResponse, util::ByteStr};
248-
use async_trait::async_trait;
249-
use bytes::{Buf, Bytes};
250-
use futures_util::stream::Stream;
251-
use http::{header, Extensions, HeaderMap, Method, Request, Response, Uri, Version};
252-
use rejection::*;
253-
use serde::de::DeserializeOwned;
254247
use std::{
255248
collections::HashMap,
256249
convert::Infallible,
@@ -260,6 +253,15 @@ use std::{
260253
task::{Context, Poll},
261254
};
262255

256+
use async_trait::async_trait;
257+
use bytes::{Buf, Bytes};
258+
use futures_util::stream::Stream;
259+
use http::{header, Extensions, HeaderMap, Method, Request, Response, Uri, Version};
260+
use rejection::*;
261+
use serde::de::DeserializeOwned;
262+
263+
use crate::{response::IntoResponse, util::ByteStr};
264+
263265
pub mod connect_info;
264266
pub mod extractor_middleware;
265267
pub mod rejection;

0 commit comments

Comments
 (0)