Skip to content

Commit 0e6939c

Browse files
GuelakaisGueLaKais
and
GueLaKais
authored
Fixup of #388 (#389)
* adde .rustfmt.toml to main repository folder * added rust_formatter.sh * added content to the rust_formatter.sh * removed rust_formatter.sh for better performance * modechange * Run rustfmt Signed-off-by: Michael X. Grey <[email protected]> * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` * Run rustfmt Does change the things described in the newly added `.rustfmt.toml` --------- Signed-off-by: Michael X. Grey <[email protected]> Co-authored-by: GueLaKais <[email protected]>
1 parent 646869b commit 0e6939c

27 files changed

+156
-138
lines changed

.rustfmt.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
imports_granularity = "Crate"
2+

rclrs/build.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
use std::env;
2-
use std::fs::read_dir;
3-
use std::path::{Path, PathBuf};
1+
use std::{
2+
env,
3+
fs::read_dir,
4+
path::{Path, PathBuf},
5+
};
46

57
const AMENT_PREFIX_PATH: &str = "AMENT_PREFIX_PATH";
68
const ROS_DISTRO: &str = "ROS_DISTRO";

rclrs/src/arguments.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use std::ffi::CString;
2-
use std::os::raw::c_char;
3-
use std::os::raw::c_void;
4-
use std::ptr::null_mut;
1+
use std::{
2+
ffi::CString,
3+
os::raw::{c_char, c_void},
4+
ptr::null_mut,
5+
};
56

6-
use crate::error::*;
7-
use crate::rcl_bindings::*;
7+
use crate::{error::*, rcl_bindings::*};
88

99
/// Extract non-ROS arguments from program's input arguments.
1010
///

rclrs/src/client.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
use std::boxed::Box;
2-
use std::collections::HashMap;
3-
use std::ffi::CString;
4-
use std::sync::atomic::AtomicBool;
5-
use std::sync::{Arc, Mutex, MutexGuard};
1+
use std::{
2+
boxed::Box,
3+
collections::HashMap,
4+
ffi::CString,
5+
sync::{atomic::AtomicBool, Arc, Mutex, MutexGuard},
6+
};
67

78
use futures::channel::oneshot;
89
use rosidl_runtime_rs::Message;
910

10-
use crate::error::{RclReturnCode, ToResult};
11-
use crate::MessageCow;
12-
use crate::{rcl_bindings::*, NodeHandle, RclrsError, ENTITY_LIFECYCLE_MUTEX};
11+
use crate::{
12+
error::{RclReturnCode, ToResult},
13+
rcl_bindings::*,
14+
MessageCow, NodeHandle, RclrsError, ENTITY_LIFECYCLE_MUTEX,
15+
};
1316

1417
// SAFETY: The functions accessing this type, including drop(), shouldn't care about the thread
1518
// they are running in. Therefore, this type can be safely sent to another thread.

rclrs/src/clock.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use crate::rcl_bindings::*;
2-
use crate::{error::ToResult, time::Time, to_rclrs_result};
1+
use crate::{error::ToResult, rcl_bindings::*, time::Time, to_rclrs_result};
32
use std::sync::{Arc, Mutex};
43

54
/// Enum to describe clock type. Redefined for readability and to eliminate the uninitialized case

rclrs/src/context.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
use std::ffi::CString;
2-
use std::os::raw::c_char;
3-
use std::string::String;
4-
use std::sync::{Arc, Mutex};
5-
use std::vec::Vec;
1+
use std::{
2+
ffi::CString,
3+
os::raw::c_char,
4+
string::String,
5+
sync::{Arc, Mutex},
6+
vec::Vec,
7+
};
68

7-
use crate::rcl_bindings::*;
8-
use crate::{RclrsError, ToResult};
9+
use crate::{rcl_bindings::*, RclrsError, ToResult};
910

1011
/// This is locked whenever initializing or dropping any middleware entity
1112
/// because we have found issues in RCL and some RMW implementations that

rclrs/src/dynamic_message.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
//!
66
//! The central type of this module is [`DynamicMessage`].
77
8-
use std::fmt::{self, Display};
9-
use std::path::PathBuf;
10-
use std::sync::Arc;
8+
use std::{
9+
fmt::{self, Display},
10+
path::PathBuf,
11+
sync::Arc,
12+
};
1113

12-
use crate::rcl_bindings::rosidl_typesupport_introspection_c__MessageMembers_s as rosidl_message_members_t;
13-
use crate::rcl_bindings::*;
14+
use crate::rcl_bindings::{
15+
rosidl_typesupport_introspection_c__MessageMembers_s as rosidl_message_members_t, *,
16+
};
1417

1518
mod error;
1619
pub use error::*;

rclrs/src/dynamic_message/error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use std::error::Error;
2-
use std::fmt;
1+
use std::{error::Error, fmt};
32

43
/// An error related to creating a dynamic message based on the name of the message's type.
54
#[derive(Debug)]

rclrs/src/error.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
use std::error::Error;
2-
use std::ffi::{CStr, NulError};
3-
use std::fmt::{self, Display};
1+
use std::{
2+
error::Error,
3+
ffi::{CStr, NulError},
4+
fmt::{self, Display},
5+
};
46

57
use crate::rcl_bindings::*;
68

rclrs/src/executor.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use crate::rcl_bindings::rcl_context_is_valid;
2-
use crate::{Node, RclReturnCode, RclrsError, WaitSet};
3-
use std::sync::{Arc, Mutex, Weak};
4-
use std::time::Duration;
1+
use crate::{rcl_bindings::rcl_context_is_valid, Node, RclReturnCode, RclrsError, WaitSet};
2+
use std::{
3+
sync::{Arc, Mutex, Weak},
4+
time::Duration,
5+
};
56

67
/// Single-threaded executor implementation.
78
pub struct SingleThreadedExecutor {

rclrs/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ mod rcl_bindings;
3030
#[cfg(feature = "dyn_msg")]
3131
pub mod dynamic_message;
3232

33-
use std::sync::Arc;
34-
use std::time::Duration;
33+
use std::{sync::Arc, time::Duration};
3534

3635
pub use arguments::*;
3736
pub use client::*;

rclrs/src/node.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
mod builder;
22
mod graph;
3-
use std::cmp::PartialEq;
4-
use std::ffi::CStr;
5-
use std::fmt;
6-
use std::os::raw::c_char;
7-
use std::sync::{Arc, Mutex, Weak};
8-
use std::vec::Vec;
3+
use std::{
4+
cmp::PartialEq,
5+
ffi::CStr,
6+
fmt,
7+
os::raw::c_char,
8+
sync::{Arc, Mutex, Weak},
9+
vec::Vec,
10+
};
911

1012
use rosidl_runtime_rs::Message;
1113

12-
pub use self::builder::*;
13-
pub use self::graph::*;
14-
use crate::rcl_bindings::*;
14+
pub use self::{builder::*, graph::*};
1515
use crate::{
16-
Client, ClientBase, Clock, Context, ContextHandle, GuardCondition, ParameterBuilder,
17-
ParameterInterface, ParameterVariant, Parameters, Publisher, QoSProfile, RclrsError, Service,
18-
ServiceBase, Subscription, SubscriptionBase, SubscriptionCallback, TimeSource,
19-
ENTITY_LIFECYCLE_MUTEX,
16+
rcl_bindings::*, Client, ClientBase, Clock, Context, ContextHandle, GuardCondition,
17+
ParameterBuilder, ParameterInterface, ParameterVariant, Parameters, Publisher, QoSProfile,
18+
RclrsError, Service, ServiceBase, Subscription, SubscriptionBase, SubscriptionCallback,
19+
TimeSource, ENTITY_LIFECYCLE_MUTEX,
2020
};
2121

2222
// SAFETY: The functions accessing this type, including drop(), shouldn't care about the thread

rclrs/src/node/builder.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
use std::ffi::CString;
2-
use std::sync::{Arc, Mutex};
1+
use std::{
2+
ffi::CString,
3+
sync::{Arc, Mutex},
4+
};
35

4-
use crate::rcl_bindings::*;
56
use crate::{
6-
ClockType, Context, ContextHandle, Node, NodeHandle, ParameterInterface, QoSProfile,
7-
RclrsError, TimeSource, ToResult, ENTITY_LIFECYCLE_MUTEX, QOS_PROFILE_CLOCK,
7+
rcl_bindings::*, ClockType, Context, ContextHandle, Node, NodeHandle, ParameterInterface,
8+
QoSProfile, RclrsError, TimeSource, ToResult, ENTITY_LIFECYCLE_MUTEX, QOS_PROFILE_CLOCK,
89
};
910

1011
/// A builder for creating a [`Node`][1].

rclrs/src/node/graph.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use std::collections::HashMap;
2-
use std::ffi::{CStr, CString};
3-
use std::slice;
1+
use std::{
2+
collections::HashMap,
3+
ffi::{CStr, CString},
4+
slice,
5+
};
46

5-
use crate::rcl_bindings::*;
6-
use crate::{Node, RclrsError, ToResult};
7+
use crate::{rcl_bindings::*, Node, RclrsError, ToResult};
78

89
impl Drop for rmw_names_and_types_t {
910
fn drop(&mut self) {

rclrs/src/parameter.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ mod value;
44
pub(crate) use override_map::*;
55
pub use value::*;
66

7-
use crate::rcl_bindings::*;
8-
use crate::{call_string_getter_with_rcl_node, RclrsError};
9-
use std::collections::{btree_map::Entry, BTreeMap};
10-
use std::fmt::Debug;
11-
use std::marker::PhantomData;
12-
use std::sync::{
13-
atomic::{AtomicBool, Ordering},
14-
Arc, Mutex, RwLock, Weak,
7+
use crate::{call_string_getter_with_rcl_node, rcl_bindings::*, RclrsError};
8+
use std::{
9+
collections::{btree_map::Entry, BTreeMap},
10+
fmt::Debug,
11+
marker::PhantomData,
12+
sync::{
13+
atomic::{AtomicBool, Ordering},
14+
Arc, Mutex, RwLock, Weak,
15+
},
1516
};
1617

1718
// This module implements the core logic of parameters in rclrs.

rclrs/src/parameter/override_map.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
use std::collections::BTreeMap;
2-
use std::ffi::CStr;
3-
use std::os::raw::c_char;
1+
use std::{collections::BTreeMap, ffi::CStr, os::raw::c_char};
42

5-
use crate::rcl_bindings::*;
6-
use crate::{ParameterValue, RclrsError, ToResult};
3+
use crate::{rcl_bindings::*, ParameterValue, RclrsError, ToResult};
74

85
// Internal helper struct, iterator for rcl_params_t
96
struct RclParamsIter<'a> {
@@ -138,9 +135,7 @@ pub(crate) unsafe fn resolve_parameter_overrides(
138135

139136
#[cfg(test)]
140137
mod tests {
141-
use std::error::Error;
142-
use std::ffi::CString;
143-
use std::io::Write;
138+
use std::{error::Error, ffi::CString, io::Write};
144139

145140
use tempfile::NamedTempFile;
146141

rclrs/src/parameter/value.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use std::ffi::CStr;
2-
use std::sync::Arc;
1+
use std::{ffi::CStr, sync::Arc};
32

4-
use crate::rcl_bindings::*;
5-
use crate::{ParameterRange, ParameterRanges, ParameterValueError};
3+
use crate::{rcl_bindings::*, ParameterRange, ParameterRanges, ParameterValueError};
64

75
/// A parameter value.
86
///

rclrs/src/publisher.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
use std::borrow::Cow;
2-
use std::ffi::CStr;
3-
use std::ffi::CString;
4-
use std::marker::PhantomData;
5-
use std::sync::{Arc, Mutex};
1+
use std::{
2+
borrow::Cow,
3+
ffi::{CStr, CString},
4+
marker::PhantomData,
5+
sync::{Arc, Mutex},
6+
};
67

78
use rosidl_runtime_rs::{Message, RmwMessage};
89

9-
use crate::error::{RclrsError, ToResult};
10-
use crate::qos::QoSProfile;
11-
use crate::rcl_bindings::*;
12-
use crate::{NodeHandle, ENTITY_LIFECYCLE_MUTEX};
10+
use crate::{
11+
error::{RclrsError, ToResult},
12+
qos::QoSProfile,
13+
rcl_bindings::*,
14+
NodeHandle, ENTITY_LIFECYCLE_MUTEX,
15+
};
1316

1417
mod loaned_message;
1518
pub use loaned_message::*;
@@ -259,8 +262,7 @@ mod tests {
259262

260263
#[test]
261264
fn test_publishers() -> Result<(), RclrsError> {
262-
use crate::TopicEndpointInfo;
263-
use crate::QOS_PROFILE_SYSTEM_DEFAULT;
265+
use crate::{TopicEndpointInfo, QOS_PROFILE_SYSTEM_DEFAULT};
264266
use test_msgs::msg;
265267

266268
let namespace = "/test_publishers_graph";

rclrs/src/publisher/loaned_message.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use std::ops::{Deref, DerefMut};
22

33
use rosidl_runtime_rs::RmwMessage;
44

5-
use crate::rcl_bindings::*;
6-
use crate::{Publisher, RclrsError, ToResult};
5+
use crate::{rcl_bindings::*, Publisher, RclrsError, ToResult};
76

87
/// A message that is owned by the middleware, loaned for publishing.
98
///

rclrs/src/service.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
use std::boxed::Box;
2-
use std::ffi::CString;
3-
use std::sync::atomic::AtomicBool;
4-
use std::sync::{Arc, Mutex, MutexGuard};
1+
use std::{
2+
boxed::Box,
3+
ffi::CString,
4+
sync::{atomic::AtomicBool, Arc, Mutex, MutexGuard},
5+
};
56

67
use rosidl_runtime_rs::Message;
78

8-
use crate::error::{RclReturnCode, ToResult};
9-
use crate::{rcl_bindings::*, MessageCow, RclrsError};
10-
use crate::{NodeHandle, ENTITY_LIFECYCLE_MUTEX};
9+
use crate::{
10+
error::{RclReturnCode, ToResult},
11+
rcl_bindings::*,
12+
MessageCow, NodeHandle, RclrsError, ENTITY_LIFECYCLE_MUTEX,
13+
};
1114

1215
// SAFETY: The functions accessing this type, including drop(), shouldn't care about the thread
1316
// they are running in. Therefore, this type can be safely sent to another thread.

rclrs/src/subscription.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
use std::ffi::CStr;
2-
use std::ffi::CString;
3-
use std::marker::PhantomData;
4-
use std::sync::atomic::AtomicBool;
5-
use std::sync::{Arc, Mutex, MutexGuard};
1+
use std::{
2+
ffi::{CStr, CString},
3+
marker::PhantomData,
4+
sync::{atomic::AtomicBool, Arc, Mutex, MutexGuard},
5+
};
66

77
use rosidl_runtime_rs::{Message, RmwMessage};
88

9-
use crate::error::{RclReturnCode, ToResult};
10-
use crate::qos::QoSProfile;
11-
use crate::{rcl_bindings::*, NodeHandle, RclrsError, ENTITY_LIFECYCLE_MUTEX};
9+
use crate::{
10+
error::{RclReturnCode, ToResult},
11+
qos::QoSProfile,
12+
rcl_bindings::*,
13+
NodeHandle, RclrsError, ENTITY_LIFECYCLE_MUTEX,
14+
};
1215

1316
mod callback;
1417
mod message_info;
@@ -327,8 +330,7 @@ mod tests {
327330

328331
#[test]
329332
fn test_subscriptions() -> Result<(), RclrsError> {
330-
use crate::TopicEndpointInfo;
331-
use crate::QOS_PROFILE_SYSTEM_DEFAULT;
333+
use crate::{TopicEndpointInfo, QOS_PROFILE_SYSTEM_DEFAULT};
332334

333335
let namespace = "/test_subscriptions_graph";
334336
let graph = construct_test_graph(namespace)?;

rclrs/src/subscription/readonly_loaned_message.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use std::ops::Deref;
22

33
use rosidl_runtime_rs::Message;
44

5-
use crate::rcl_bindings::*;
6-
use crate::{Subscription, ToResult};
5+
use crate::{rcl_bindings::*, Subscription, ToResult};
76

87
/// A message that is owned by the middleware, loaned out for reading.
98
///

0 commit comments

Comments
 (0)