Skip to content

Commit

Permalink
Run rustfmt using new configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry73204 authored and m-dahl committed Apr 8, 2024
1 parent aad542f commit 95fdea3
Show file tree
Hide file tree
Showing 46 changed files with 277 additions and 294 deletions.
3 changes: 1 addition & 2 deletions r2r/benches/deserialization.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use criterion::{criterion_group, criterion_main, Criterion};
use r2r::*;
use rand::thread_rng;
use rand::Rng;
use rand::{thread_rng, Rng};

const NUM_ELEMENTS: usize = 10_000;
const NUM_TIMES: usize = 1_000;
Expand Down
6 changes: 4 additions & 2 deletions r2r/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ use {
std::io::{self, prelude::*, BufWriter},
};

use std::path::{Path, PathBuf};
use std::{env, fs};
use std::{
env, fs,
path::{Path, PathBuf},
};

#[cfg(feature = "doc-only")]
mod filenames {
Expand Down
5 changes: 1 addition & 4 deletions r2r/examples/action_client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use futures::executor::LocalPool;
use futures::future::FutureExt;
use futures::stream::StreamExt;
use futures::task::LocalSpawnExt;
use futures::{executor::LocalPool, future::FutureExt, stream::StreamExt, task::LocalSpawnExt};

use r2r::example_interfaces::action::Fibonacci;
use std::sync::{Arc, Mutex};
Expand Down
5 changes: 1 addition & 4 deletions r2r/examples/action_client_untyped.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
//
// This example is the same as action_client.rs but stripped of all (explicit) type information.
//
use futures::executor::LocalPool;
use futures::future::FutureExt;
use futures::stream::StreamExt;
use futures::task::LocalSpawnExt;
use futures::{executor::LocalPool, future::FutureExt, stream::StreamExt, task::LocalSpawnExt};

use std::sync::{Arc, Mutex};

Expand Down
10 changes: 6 additions & 4 deletions r2r/examples/action_server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use futures::executor::{LocalPool, LocalSpawner};
use futures::future::{self, Either};
use futures::stream::{Stream, StreamExt};
use futures::task::LocalSpawnExt;
use futures::{
executor::{LocalPool, LocalSpawner},
future::{self, Either},
stream::{Stream, StreamExt},
task::LocalSpawnExt,
};

use r2r::example_interfaces::action::Fibonacci;
use std::sync::{Arc, Mutex};
Expand Down
4 changes: 1 addition & 3 deletions r2r/examples/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use futures::executor::LocalPool;
use futures::task::LocalSpawnExt;
use futures::Future;
use futures::{executor::LocalPool, task::LocalSpawnExt, Future};

use std::io::Write;

Expand Down
4 changes: 1 addition & 3 deletions r2r/examples/parameters.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use futures::executor::LocalPool;
use futures::prelude::*;
use futures::task::LocalSpawnExt;
use futures::{executor::LocalPool, prelude::*, task::LocalSpawnExt};

// try to run like this
// cargo run --example parameters -- --ros-args -p key1:=[hello,world] -p key2:=5.5 -r __ns:=/demo -r __node:=my_node
Expand Down
4 changes: 1 addition & 3 deletions r2r/examples/parameters_derive.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use futures::executor::LocalPool;
use futures::prelude::*;
use futures::task::LocalSpawnExt;
use futures::{executor::LocalPool, prelude::*, task::LocalSpawnExt};
use r2r::RosParams;
use std::sync::{Arc, Mutex};

Expand Down
7 changes: 3 additions & 4 deletions r2r/examples/publishers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use r2r::builtin_interfaces::msg::Duration;
use r2r::std_msgs::msg::Int32;
use r2r::trajectory_msgs::msg::*;
use r2r::QosProfile;
use r2r::{
builtin_interfaces::msg::Duration, std_msgs::msg::Int32, trajectory_msgs::msg::*, QosProfile,
};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let ctx = r2r::Context::create()?;
Expand Down
9 changes: 2 additions & 7 deletions r2r/examples/rostopic_echo.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
use futures::executor::LocalPool;
use futures::future;
use futures::stream::StreamExt;
use futures::task::LocalSpawnExt;
use futures::{executor::LocalPool, future, stream::StreamExt, task::LocalSpawnExt};
use r2r::QosProfile;

use std::collections::HashMap;
use std::env;
use std::thread;
use std::{collections::HashMap, env, thread};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let ctx = r2r::Context::create()?;
Expand Down
3 changes: 1 addition & 2 deletions r2r/examples/rostopic_list.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::thread;
use std::time::Duration;
use std::{thread, time::Duration};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let ctx = r2r::Context::create()?;
Expand Down
7 changes: 1 addition & 6 deletions r2r/examples/service.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use futures::executor::LocalPool;
use futures::select;
use futures::stream::StreamExt;
use futures::task::LocalSpawnExt;
use futures::FutureExt;
use futures::{executor::LocalPool, select, stream::StreamExt, task::LocalSpawnExt, FutureExt};

use r2r::example_interfaces::srv::AddTwoInts;

Expand All @@ -12,7 +8,6 @@ use r2r::example_interfaces::srv::AddTwoInts;
/// Run toghtether with the client example.
/// e.g. cargo run --example service
/// and in another terminal cargo run --example client
///
fn main() -> Result<(), Box<dyn std::error::Error>> {
let ctx = r2r::Context::create()?;
let mut node = r2r::Node::create(ctx, "testnode", "")?;
Expand Down
3 changes: 1 addition & 2 deletions r2r/examples/sim_time_publisher.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use r2r::ClockType::SystemTime;
use r2r::{Clock, QosProfile};
use r2r::{Clock, ClockType::SystemTime, QosProfile};
use std::time::Duration;

/// Simple publisher publishing time starting at time 0 every `SENDING_PERIOD`
Expand Down
5 changes: 1 addition & 4 deletions r2r/examples/subscriber.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use futures::executor::LocalPool;
use futures::future;
use futures::stream::StreamExt;
use futures::task::LocalSpawnExt;
use futures::{executor::LocalPool, future, stream::StreamExt, task::LocalSpawnExt};
use r2r::QosProfile;

fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down
11 changes: 6 additions & 5 deletions r2r/examples/timer_sim_time.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use futures::executor::LocalPool;
use futures::task::LocalSpawnExt;
use futures::{executor::LocalPool, task::LocalSpawnExt};

use r2r::{Clock, ClockType};
use std::cell::RefCell;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use std::{
cell::RefCell,
rc::Rc,
sync::{Arc, Mutex},
};

async fn timer_task(
mut t: r2r::Timer, ros_clock: Arc<Mutex<Clock>>, mut system_clock: Clock,
Expand Down
3 changes: 1 addition & 2 deletions r2r/examples/tokio.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use futures::future;
use futures::stream::StreamExt;
use futures::{future, stream::StreamExt};
use r2r::QosProfile;

use std::sync::{Arc, Mutex};
Expand Down
3 changes: 1 addition & 2 deletions r2r/examples/tokio_examples.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::sync::{Arc, Mutex};

use futures::future;
use futures::stream::StreamExt;
use futures::{future, stream::StreamExt};

use r2r::QosProfile;
use tokio::task;
Expand Down
3 changes: 1 addition & 2 deletions r2r/examples/tokio_raw_publisher.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use r2r::QosProfile;
use r2r::WrappedTypesupport;
use r2r::{QosProfile, WrappedTypesupport};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down
6 changes: 2 additions & 4 deletions r2r/examples/tokio_raw_subscriber.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use futures::future;
use futures::stream::StreamExt;
use r2r::QosProfile;
use r2r::WrappedTypesupport;
use futures::{future, stream::StreamExt};
use r2r::{QosProfile, WrappedTypesupport};
use serde::{Deserialize, Serialize};

#[tokio::main]
Expand Down
3 changes: 1 addition & 2 deletions r2r/examples/tokio_subscriber.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use futures::future;
use futures::stream::StreamExt;
use futures::{future, stream::StreamExt};
use r2r::QosProfile;

#[tokio::main]
Expand Down
4 changes: 1 addition & 3 deletions r2r/examples/untyped_client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use futures::executor::LocalPool;
use futures::task::LocalSpawnExt;
use futures::Future;
use futures::{executor::LocalPool, task::LocalSpawnExt, Future};

async fn requester_task(
node_available: impl Future<Output = r2r::Result<()>>, c: r2r::ClientUntyped,
Expand Down
6 changes: 2 additions & 4 deletions r2r/examples/wall_timer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use futures::executor::LocalPool;
use futures::task::LocalSpawnExt;
use futures::{executor::LocalPool, task::LocalSpawnExt};

use std::cell::RefCell;
use std::rc::Rc;
use std::{cell::RefCell, rc::Rc};

async fn timer_task(mut t: r2r::Timer) -> Result<(), Box<dyn std::error::Error>> {
let mut x: i32 = 0;
Expand Down
34 changes: 21 additions & 13 deletions r2r/src/action_clients.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
use futures::channel::{mpsc, oneshot};
use futures::future::{FutureExt, TryFutureExt};
use futures::stream::Stream;
use std::collections::HashMap;
use std::ffi::CString;
use std::future::Future;
use std::mem::MaybeUninit;
use std::sync::{Mutex, Weak};

use crate::action_common::*;
use crate::error::*;
use crate::msg_types::generated_msgs::{action_msgs, builtin_interfaces, unique_identifier_msgs};
use crate::msg_types::*;
use futures::{
channel::{mpsc, oneshot},
future::{FutureExt, TryFutureExt},
stream::Stream,
};
use std::{
collections::HashMap,
ffi::CString,
future::Future,
mem::MaybeUninit,
sync::{Mutex, Weak},
};

use crate::{
action_common::*,
error::*,
msg_types::{
generated_msgs::{action_msgs, builtin_interfaces, unique_identifier_msgs},
*,
},
};
use r2r_actions::*;
use r2r_rcl::*;

Expand Down
34 changes: 21 additions & 13 deletions r2r/src/action_clients_untyped.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
use futures::channel::{mpsc, oneshot};
use futures::future::{FutureExt, TryFutureExt};
use futures::stream::Stream;
use std::collections::HashMap;
use std::future::Future;
use std::mem::MaybeUninit;
use std::sync::{Mutex, Weak};

use crate::action_clients::*;
use crate::action_common::*;
use crate::error::*;
use crate::msg_types::generated_msgs::{action_msgs, builtin_interfaces, unique_identifier_msgs};
use crate::msg_types::*;
use futures::{
channel::{mpsc, oneshot},
future::{FutureExt, TryFutureExt},
stream::Stream,
};
use std::{
collections::HashMap,
future::Future,
mem::MaybeUninit,
sync::{Mutex, Weak},
};

use crate::{
action_clients::*,
action_common::*,
error::*,
msg_types::{
generated_msgs::{action_msgs, builtin_interfaces, unique_identifier_msgs},
*,
},
};
use r2r_actions::*;
use r2r_rcl::*;
//
Expand Down
31 changes: 19 additions & 12 deletions r2r/src/action_servers.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
use futures::channel::{mpsc, oneshot};
use futures::future::FutureExt;
use futures::future::{join_all, JoinAll};
use futures::stream::Stream;
use std::collections::HashMap;
use std::ffi::CString;
use std::mem::MaybeUninit;
use std::sync::{Arc, Mutex, Weak};

use crate::error::*;
use crate::msg_types::generated_msgs::{action_msgs, builtin_interfaces, unique_identifier_msgs};
use crate::msg_types::*;
use futures::{
channel::{mpsc, oneshot},
future::{join_all, FutureExt, JoinAll},
stream::Stream,
};
use std::{
collections::HashMap,
ffi::CString,
mem::MaybeUninit,
sync::{Arc, Mutex, Weak},
};

use crate::{
error::*,
msg_types::{
generated_msgs::{action_msgs, builtin_interfaces, unique_identifier_msgs},
*,
},
};
use r2r_actions::*;
use r2r_rcl::*;

Expand Down
18 changes: 9 additions & 9 deletions r2r/src/clients.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use futures::channel::oneshot;
use futures::TryFutureExt;
use std::ffi::CString;
use std::future::Future;
use std::mem::MaybeUninit;
use std::sync::{Mutex, Weak};

use crate::error::*;
use crate::msg_types::*;
use futures::{channel::oneshot, TryFutureExt};
use std::{
ffi::CString,
future::Future,
mem::MaybeUninit,
sync::{Mutex, Weak},
};

use crate::{error::*, msg_types::*};
use r2r_rcl::*;

/// ROS service client.
Expand Down
7 changes: 2 additions & 5 deletions r2r/src/clocks.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use std::fmt::Debug;
use std::mem::MaybeUninit;
use std::time::Duration;
use std::{fmt::Debug, mem::MaybeUninit, time::Duration};

use crate::error::*;
use crate::msg_types::generated_msgs::builtin_interfaces;
use crate::{error::*, msg_types::generated_msgs::builtin_interfaces};
use r2r_rcl::*;

/// Different ROS clock types.
Expand Down
17 changes: 8 additions & 9 deletions r2r/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use std::ffi::CStr;
use std::ffi::CString;
use std::fmt::Debug;
use std::ops::{Deref, DerefMut};
use std::sync::OnceLock;
use std::sync::{Arc, Mutex};

use crate::error::*;
use crate::log_guard;
use std::{
ffi::{CStr, CString},
fmt::Debug,
ops::{Deref, DerefMut},
sync::{Arc, Mutex, OnceLock},
};

use crate::{error::*, log_guard};
use r2r_rcl::*;

/// A ROS context. Needed to create nodes etc.
Expand Down
Loading

0 comments on commit 95fdea3

Please sign in to comment.