Skip to content

Commit eb58314

Browse files
committed
Apply cargo fmt
Signed-off-by: Michael X. Grey <[email protected]>
1 parent 4110a3c commit eb58314

34 files changed

+3930
-2909
lines changed

generate_bindings/src/main.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use cargo_manifest::Manifest;
2-
use std::path::Path;
3-
use std::fs::read_dir;
2+
use std::{fs::read_dir, path::Path};
43

54
const AMENT_PREFIX_PATH: &str = "AMENT_PREFIX_PATH";
65
const ROS_DISTRO: &str = "ROS_DISTRO";
@@ -23,12 +22,18 @@ fn main() {
2322

2423
let Ok(workspace) = Manifest::from_path("Cargo.toml")
2524
.map_err(|_| ())
26-
.and_then(|manifest| manifest.workspace.ok_or(())) else
27-
{
28-
panic!(" > ERROR: Run the generate_bindings script from the root Cargo workspace of ros2_rust");
25+
.and_then(|manifest| manifest.workspace.ok_or(()))
26+
else {
27+
panic!(
28+
" > ERROR: Run the generate_bindings script from the root Cargo workspace of ros2_rust"
29+
);
2930
};
3031

31-
let has_rclrs = workspace.members.iter().find(|member | *member == "rclrs").is_some();
32+
let has_rclrs = workspace
33+
.members
34+
.iter()
35+
.find(|member| *member == "rclrs")
36+
.is_some();
3237
if !has_rclrs {
3338
panic!(
3439
" > ERROR: Run the generate_bindings script from the root Cargo workspace of ros2_rust. \
@@ -91,5 +96,7 @@ fn main() {
9196

9297
let bindings = builder.generate().expect("Unable to generate bindings");
9398
let bindings_path = format!("rclrs/src/rcl_bindings_generated_{ros_distro}.rs");
94-
bindings.write_to_file(bindings_path).expect("Failed to generate bindings");
99+
bindings
100+
.write_to_file(bindings_path)
101+
.expect("Failed to generate bindings");
95102
}

rclrs/src/action.rs

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,9 @@ pub use action_goal_receiver::*;
99
pub(crate) mod action_server;
1010
pub use action_server::*;
1111

12-
use crate::{
13-
rcl_bindings::*,
14-
vendor::builtin_interfaces::msg::Time,
15-
DropGuard,
16-
log_error,
17-
};
12+
use crate::{log_error, rcl_bindings::*, vendor::builtin_interfaces::msg::Time, DropGuard};
1813
use std::fmt;
1914

20-
2115
/// A unique identifier for a goal request.
2216
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2317
pub struct GoalUuid(pub [u8; RCL_ACTION_UUID_SIZE]);
@@ -222,36 +216,41 @@ fn empty_goal_status_array() -> DropGuard<rcl_action_goal_status_array_t> {
222216
// SAFETY: The goal_status array is either zero-initialized and empty or populated by
223217
// `rcl_action_get_goal_status_array`. In either case, it can be safely finalized.
224218
rcl_action_goal_status_array_fini(&mut goal_statuses);
225-
}
219+
},
226220
)
227221
}
228222

229223
#[cfg(test)]
230224
mod tests {
231-
use crate::*;
232-
use crate::vendor::example_interfaces::action::{Fibonacci, Fibonacci_Goal, Fibonacci_Result, Fibonacci_Feedback};
233-
use tokio::sync::mpsc::unbounded_channel;
225+
use crate::{
226+
vendor::example_interfaces::action::{
227+
Fibonacci, Fibonacci_Feedback, Fibonacci_Goal, Fibonacci_Result,
228+
},
229+
*,
230+
};
234231
use futures::StreamExt;
235232
use std::time::Duration;
233+
use tokio::sync::mpsc::unbounded_channel;
236234

237235
#[test]
238236
fn test_action_success() {
239237
let mut executor = Context::default().create_basic_executor();
240238

241-
let node = executor.create_node(&format!("test_action_success_{}", line!())).unwrap();
239+
let node = executor
240+
.create_node(&format!("test_action_success_{}", line!()))
241+
.unwrap();
242242
let action_name = format!("test_action_success_{}_action", line!());
243-
let _action_server = node.create_action_server(
244-
&action_name,
245-
fibonacci_action,
246-
).unwrap();
243+
let _action_server = node
244+
.create_action_server(&action_name, fibonacci_action)
245+
.unwrap();
247246

248-
let client = node.create_action_client::<Fibonacci>(&action_name).unwrap();
247+
let client = node
248+
.create_action_client::<Fibonacci>(&action_name)
249+
.unwrap();
249250

250251
let order_10_sequence = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
251252

252-
let request = client.request_goal(Fibonacci_Goal {
253-
order: 10,
254-
});
253+
let request = client.request_goal(Fibonacci_Goal { order: 10 });
255254

256255
let promise = executor.commands().run(async move {
257256
let mut goal_client_stream = request.await.unwrap().stream();
@@ -264,7 +263,12 @@ mod tests {
264263
}
265264
GoalEvent::Status(s) => {
266265
assert!(
267-
matches!(s.code, GoalStatusCode::Unknown | GoalStatusCode::Executing | GoalStatusCode::Succeeded),
266+
matches!(
267+
s.code,
268+
GoalStatusCode::Unknown
269+
| GoalStatusCode::Executing
270+
| GoalStatusCode::Succeeded
271+
),
268272
"Actual code: {:?}",
269273
s.code,
270274
);
@@ -280,9 +284,7 @@ mod tests {
280284

281285
executor.spin(SpinOptions::default().until_promise_resolved(promise));
282286

283-
let request = client.request_goal(Fibonacci_Goal {
284-
order: 10,
285-
});
287+
let request = client.request_goal(Fibonacci_Goal { order: 10 });
286288

287289
let promise = executor.commands().run(async move {
288290
let (status, result) = request.await.unwrap().result.await;
@@ -310,7 +312,6 @@ mod tests {
310312

311313
let (sender, mut receiver) = unbounded_channel();
312314
std::thread::spawn(move || {
313-
314315
let mut previous = 0;
315316
let mut current = 1;
316317

@@ -333,11 +334,9 @@ mod tests {
333334
Ok(Some(next)) => {
334335
// We have a new item in the sequence
335336
sequence.push(next);
336-
executing.publish_feedback(
337-
Fibonacci_Feedback {
338-
sequence: sequence.clone(),
339-
}
340-
);
337+
executing.publish_feedback(Fibonacci_Feedback {
338+
sequence: sequence.clone(),
339+
});
341340
}
342341
Ok(None) => {
343342
// The sequence has finished

0 commit comments

Comments
 (0)