Skip to content

Commit 194e996

Browse files
committed
chore: Organize imports automatically
`Makefile`: - `imports_granularity` is set to `Crate` because I find it the option that most helps me to see how imports relate to each other and it results in the most concise imports. One drawback is that it tends to lead to more merge conflicts, but on this project merges and rebases are rare so this shouldn't be a problem in practice.
1 parent d7cbc38 commit 194e996

File tree

8 files changed

+44
-29
lines changed

8 files changed

+44
-29
lines changed

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ check_docs:
175175

176176
## Check that the code is formatted correctly
177177
check_format:
178-
cargo fmt --check
178+
cargo fmt \
179+
--check \
180+
-- \
181+
--config imports_granularity=Crate,group_imports=StdExternalCrate
179182
.PHONY: check_format
180183

181184
## Check that generated files are up to date
@@ -241,7 +244,9 @@ check_tests:
241244

242245
## Attempt to fix formatting automatically
243246
fix_format:
244-
cargo fmt
247+
cargo fmt \
248+
-- \
249+
--config imports_granularity=Crate,group_imports=StdExternalCrate
245250
.PHONY: fix_format
246251

247252
## Attempt to fix lints automatically

apps/event_subscribe/src/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
//! An example of how to subscribe to manual trigger events using `axevent::nonblock`
33
44
use anyhow::Context;
5-
use axevent::flex::{Handler, KeyValueSet};
6-
use axevent::nonblock::Subscription;
5+
use axevent::{
6+
flex::{Handler, KeyValueSet},
7+
nonblock::Subscription,
8+
};
9+
use futures_lite::StreamExt;
710
use glib::MainContext;
811
use log::{error, info};
912

10-
use futures_lite::StreamExt;
11-
1213
async fn app() -> anyhow::Result<()> {
1314
let mut subscription_template = KeyValueSet::new();
1415
subscription_template

apps/subscribe_to_event/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
//! installed and running as it relies on those events to receive and log data.
44
55
use axevent::flex::{Handler, KeyValueSet, Subscription};
6-
use log::error;
7-
use log::info;
6+
use log::{error, info};
87

98
fn onviftrigger_subscription(handler: &Handler, token: u32) -> anyhow::Result<Subscription> {
109
let mut key_value_set = KeyValueSet::new();

crates/axevent/src/nonblock.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ use std::{
55
task::{Context, Poll},
66
};
77

8-
use crate::flex::{Event, Handler, KeyValueSet};
98
use async_channel::Receiver;
109
use futures_lite::Stream;
1110
use log::{error, warn};
1211

12+
use crate::flex::{Event, Handler, KeyValueSet};
13+
1314
/// Represents an event subscription that can be iterated asynchronously
1415
///
1516
/// # Panics

crates/axstorage/src/flex.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
use std::{
2+
ffi::{c_char, c_void, CStr, OsStr},
3+
mem,
4+
mem::ManuallyDrop,
5+
path::Path,
6+
ptr,
7+
ptr::NonNull,
8+
};
9+
110
use axstorage_sys::{
211
ax_storage_error_quark, ax_storage_get_path, ax_storage_get_status, ax_storage_get_storage_id,
312
ax_storage_get_type, ax_storage_list, ax_storage_release_async, ax_storage_setup_async,
@@ -19,15 +28,6 @@ use glib::{
1928
GStringPtr, List, Quark,
2029
};
2130
use glib_sys::{g_free, g_strdup, gpointer, GTRUE};
22-
use std::ffi::OsStr;
23-
use std::path::Path;
24-
use std::{
25-
ffi::{c_char, c_void, CStr},
26-
mem,
27-
mem::ManuallyDrop,
28-
ptr,
29-
ptr::NonNull,
30-
};
3131
// The documentation states that we are responsible for freeing the callbacks, but it does state
3232
// when it is safe to do so making it impossible to create a Rust abstraction that both:
3333
// - does not leak memory and

crates/ffi_patterns/src/sys.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
use std::collections::HashMap;
2-
use std::ffi::{c_int, c_void};
1+
use std::{
2+
collections::HashMap,
3+
ffi::{c_int, c_void},
4+
};
35

46
type Callback = unsafe extern "C" fn(*mut c_void);
57

crates/ffi_patterns/src/tests.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
use std::{
2+
collections::HashMap,
3+
ffi::c_void,
4+
marker::PhantomData,
5+
sync::{
6+
atomic::{AtomicUsize, Ordering},
7+
Mutex,
8+
},
9+
thread::{spawn, JoinHandle},
10+
};
11+
112
use crate::sys;
2-
use std::collections::HashMap;
3-
use std::ffi::c_void;
4-
use std::marker::PhantomData;
5-
use std::sync::atomic::{AtomicUsize, Ordering};
6-
use std::sync::Mutex;
7-
use std::thread::{spawn, JoinHandle};
813

914
/// A struct that calls a function when dropped.
1015
/// This is intended to help make sure pointers are cleaned up at an appropriate time.

crates/mdb/src/error.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
use std::ffi::{c_char, CStr};
2-
use std::fmt::{Debug, Display, Formatter};
3-
use std::marker::PhantomData;
1+
use std::{
2+
ffi::{c_char, CStr},
3+
fmt::{Debug, Display, Formatter},
4+
marker::PhantomData,
5+
};
46

57
unsafe fn pchar_to_string(p_value: *const c_char) -> String {
68
assert!(!p_value.is_null());

0 commit comments

Comments
 (0)