Skip to content

Commit 9024b83

Browse files
committed
chore: apply group_imports = "StdExternalCrate"[1]
Unmerge a few excessively complex import statements. The option itself is unstable, so it is commented in rustfmt.toml. [1]: https://rust-lang.github.io/rustfmt/?version=master&search=#group_imports
1 parent 1869072 commit 9024b83

File tree

15 files changed

+58
-54
lines changed

15 files changed

+58
-54
lines changed

examples/async.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
use std::ffi::{c_char, c_void};
2+
use std::ptr::{addr_of, addr_of_mut};
3+
use std::sync::atomic::AtomicBool;
4+
use std::sync::Arc;
5+
use std::time::Instant;
6+
17
use ngx::core;
28
use ngx::ffi::{
39
nginx_version, ngx_array_push, ngx_command_t, ngx_conf_t, ngx_cycle, ngx_event_t, ngx_http_core_module,
@@ -7,11 +13,6 @@ use ngx::ffi::{
713
};
814
use ngx::http::{self, HTTPModule, MergeConfigError};
915
use ngx::{http_request_handler, ngx_log_debug_http, ngx_null_command, ngx_string};
10-
use std::ffi::{c_char, c_void};
11-
use std::ptr::{addr_of, addr_of_mut};
12-
use std::sync::atomic::AtomicBool;
13-
use std::sync::Arc;
14-
use std::time::Instant;
1516
use tokio::runtime::Runtime;
1617

1718
struct Module;

examples/awssig.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use std::ffi::{c_char, c_void};
2+
use std::ptr::addr_of;
3+
14
use http::HeaderMap;
25
use ngx::core;
36
use ngx::ffi::{
@@ -8,8 +11,6 @@ use ngx::ffi::{
811
};
912
use ngx::http::*;
1013
use ngx::{http_request_handler, ngx_log_debug_http, ngx_null_command, ngx_string};
11-
use std::ffi::{c_char, c_void};
12-
use std::ptr::addr_of;
1314

1415
struct Module;
1516

examples/curl.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use std::ffi::{c_char, c_void};
2+
use std::ptr::addr_of;
3+
14
use ngx::core;
25
use ngx::ffi::{
36
nginx_version, ngx_array_push, ngx_command_t, ngx_conf_t, ngx_http_core_module, ngx_http_handler_pt,
@@ -6,8 +9,6 @@ use ngx::ffi::{
69
};
710
use ngx::http::{self, HTTPModule, MergeConfigError};
811
use ngx::{http_request_handler, ngx_log_debug_http, ngx_null_command, ngx_string};
9-
use std::ffi::{c_char, c_void};
10-
use std::ptr::addr_of;
1112

1213
struct Module;
1314

examples/httporigdst.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use std::ffi::{c_char, c_int, c_void};
2+
use std::ptr::addr_of;
3+
14
use ngx::core;
25
use ngx::ffi::{
36
in_port_t, nginx_version, ngx_conf_t, ngx_connection_local_sockaddr, ngx_http_add_variable, ngx_http_module_t,
@@ -6,8 +9,6 @@ use ngx::ffi::{
69
};
710
use ngx::http::{self, HTTPModule};
811
use ngx::{http_variable_get, ngx_http_null_variable, ngx_log_debug_http, ngx_null_string, ngx_string};
9-
use std::ffi::{c_char, c_int, c_void};
10-
use std::ptr::addr_of;
1112

1213
const IPV4_STRLEN: usize = INET_ADDRSTRLEN as usize;
1314

examples/upstream.rs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,26 @@
66
* The NGINX authors are grateful to @gabihodoroaga for their contributions
77
* to the community at large.
88
*/
9-
use ngx::{
10-
core::{Pool, Status},
11-
ffi::{
12-
nginx_version, ngx_atoi, ngx_command_t, ngx_conf_log_error, ngx_conf_t, ngx_connection_t,
13-
ngx_event_free_peer_pt, ngx_event_get_peer_pt, ngx_http_module_t, ngx_http_upstream_init_peer_pt,
14-
ngx_http_upstream_init_pt, ngx_http_upstream_init_round_robin, ngx_http_upstream_module,
15-
ngx_http_upstream_srv_conf_t, ngx_http_upstream_t, ngx_int_t, ngx_module_t, ngx_peer_connection_t, ngx_str_t,
16-
ngx_uint_t, NGX_CONF_NOARGS, NGX_CONF_TAKE1, NGX_CONF_UNSET, NGX_ERROR, NGX_HTTP_MODULE, NGX_HTTP_UPS_CONF,
17-
NGX_LOG_EMERG, NGX_RS_HTTP_SRV_CONF_OFFSET, NGX_RS_MODULE_SIGNATURE,
18-
},
19-
http::{
20-
ngx_http_conf_get_module_srv_conf, ngx_http_conf_upstream_srv_conf_immutable,
21-
ngx_http_conf_upstream_srv_conf_mutable, HTTPModule, Merge, MergeConfigError, Request,
22-
},
23-
http_upstream_init_peer_pt,
24-
log::DebugMask,
25-
ngx_log_debug_http, ngx_log_debug_mask, ngx_null_command, ngx_string,
9+
use std::ffi::{c_char, c_void};
10+
use std::mem;
11+
use std::ptr::addr_of;
12+
use std::slice;
13+
14+
use ngx::core::{Pool, Status};
15+
use ngx::ffi::{
16+
nginx_version, ngx_atoi, ngx_command_t, ngx_conf_log_error, ngx_conf_t, ngx_connection_t, ngx_event_free_peer_pt,
17+
ngx_event_get_peer_pt, ngx_http_module_t, ngx_http_upstream_init_peer_pt, ngx_http_upstream_init_pt,
18+
ngx_http_upstream_init_round_robin, ngx_http_upstream_module, ngx_http_upstream_srv_conf_t, ngx_http_upstream_t,
19+
ngx_int_t, ngx_module_t, ngx_peer_connection_t, ngx_str_t, ngx_uint_t, NGX_CONF_NOARGS, NGX_CONF_TAKE1,
20+
NGX_CONF_UNSET, NGX_ERROR, NGX_HTTP_MODULE, NGX_HTTP_UPS_CONF, NGX_LOG_EMERG, NGX_RS_HTTP_SRV_CONF_OFFSET,
21+
NGX_RS_MODULE_SIGNATURE,
2622
};
27-
use std::{
28-
ffi::{c_char, c_void},
29-
mem,
30-
ptr::addr_of,
31-
slice,
23+
use ngx::http::{
24+
ngx_http_conf_get_module_srv_conf, ngx_http_conf_upstream_srv_conf_immutable,
25+
ngx_http_conf_upstream_srv_conf_mutable, HTTPModule, Merge, MergeConfigError, Request,
3226
};
27+
use ngx::log::DebugMask;
28+
use ngx::{http_upstream_init_peer_pt, ngx_log_debug_http, ngx_log_debug_mask, ngx_null_command, ngx_string};
3329

3430
#[derive(Clone, Copy, Debug)]
3531
#[repr(C)]

rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# group_imports = "StdExternalCrate" # unstable
12
max_width = 120

src/core/buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::ffi::*;
2-
31
use std::slice;
42

3+
use crate::ffi::*;
4+
55
/// The `Buffer` trait provides methods for working with an nginx buffer (`ngx_buf_t`).
66
pub trait Buffer {
77
/// Returns a raw pointer to the underlying `ngx_buf_t` of the buffer.

src/core/pool.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use crate::core::buffer::{Buffer, MemoryBuffer, TemporaryBuffer};
2-
use crate::ffi::*;
3-
41
use std::ffi::c_void;
52
use std::{mem, ptr};
63

4+
use crate::core::buffer::{Buffer, MemoryBuffer, TemporaryBuffer};
5+
use crate::ffi::*;
6+
77
/// Wrapper struct for an `ngx_pool_t` pointer, providing methods for working with memory pools.
88
pub struct Pool(*mut ngx_pool_t);
99

src/core/status.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use crate::ffi::*;
21
use std::fmt;
32

3+
use crate::ffi::*;
4+
45
/// Status
56
///
67
/// Rust native wrapper for NGINX status codes.

src/core/string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use crate::ffi::*;
2-
31
use std::borrow::Cow;
42
use std::slice;
53
use std::str::{self, Utf8Error};
64

5+
use crate::ffi::*;
6+
77
/// Static string initializer for [`ngx_str_t`].
88
///
99
/// The resulting byte string is always nul-terminated (just like a C string).

0 commit comments

Comments
 (0)