Skip to content

Commit

Permalink
Use nightly for style check (#396)
Browse files Browse the repository at this point in the history
* Use nightly for style check

Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>

* Install nightly for cargo +nightly fmt

Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>

* Fix style in examples

Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>

* Update style for rosidl_runtime_rs

Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>

* Add a comment indicating that nightly release is needed for formatting

Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>

---------

Signed-off-by: Michael X. Grey <mxgrey@intrinsic.ai>
  • Loading branch information
mxgrey authored May 13, 2024
1 parent 875bda3 commit 2e746d6
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ jobs:
run: |
for path in $(colcon list | awk '$3 == "(ament_cargo)" { print $2 }'); do
cd $path
cargo fmt -- --check
rustup toolchain install nightly
cargo +nightly fmt -- --check
cd -
done
Expand Down
3 changes: 2 additions & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# This requires the nightly release of Rust, so when formating the repo, use
# $ cargo +nightly fmt
imports_granularity = "Crate"

4 changes: 1 addition & 3 deletions examples/message_demo/src/message_demo.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::convert::TryInto;
use std::env;
use std::sync::Arc;
use std::{convert::TryInto, env, sync::Arc};

use anyhow::{Error, Result};
use rosidl_runtime_rs::{seq, BoundedSequence, Message, Sequence};
Expand Down
10 changes: 7 additions & 3 deletions examples/minimal_pub_sub/src/minimal_two_nodes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use std::env;
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::{Arc, Mutex};
use std::{
env,
sync::{
atomic::{AtomicU32, Ordering},
Arc, Mutex,
},
};

use anyhow::{Error, Result};

Expand Down
12 changes: 7 additions & 5 deletions rosidl_runtime_rs/src/sequence.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use std::cmp::Ordering;
use std::fmt::{self, Debug, Display};
use std::hash::{Hash, Hasher};
use std::iter::{Extend, FromIterator, FusedIterator};
use std::ops::{Deref, DerefMut};
use std::{
cmp::Ordering,
fmt::{self, Debug, Display},
hash::{Hash, Hasher},
iter::{Extend, FromIterator, FusedIterator},
ops::{Deref, DerefMut},
};

#[cfg(feature = "serde")]
mod serde;
Expand Down
15 changes: 8 additions & 7 deletions rosidl_runtime_rs/src/string.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use std::cmp::Ordering;
use std::ffi::CStr;
use std::fmt::{self, Debug, Display};
use std::hash::{Hash, Hasher};
use std::ops::{Deref, DerefMut};
use std::{
cmp::Ordering,
ffi::CStr,
fmt::{self, Debug, Display},
hash::{Hash, Hasher},
ops::{Deref, DerefMut},
};

#[cfg(feature = "serde")]
mod serde;

use crate::sequence::Sequence;
use crate::traits::SequenceAlloc;
use crate::{sequence::Sequence, traits::SequenceAlloc};

/// A zero-terminated UTF-8 string.
///
Expand Down
3 changes: 1 addition & 2 deletions rosidl_runtime_rs/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
// DISTRIBUTION A. Approved for public release; distribution unlimited.
// OPSEC #4584.
//
use std::borrow::Cow;
use std::fmt::Debug;
use std::{borrow::Cow, fmt::Debug};

/// Internal trait that connects a particular `Sequence<T>` instance to generated C functions
/// that allocate and deallocate memory.
Expand Down

0 comments on commit 2e746d6

Please sign in to comment.