Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
roboticswithjulia authored Dec 6, 2024
2 parents a80fcfd + f706824 commit e8f7138
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 40 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/rust-minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ jobs:
- name: Search packages in this repository
id: list_packages
run: |
echo ::set-output name=package_list::$(colcon list --names-only)
{
echo 'package_list<<EOF'
colcon list --names-only
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Setup ROS environment
uses: ros-tooling/[email protected]
Expand All @@ -72,10 +76,6 @@ jobs:
cd -
done
- name: Install cargo-ament-build
run: |
cargo install --debug cargo-ament-build
- name: Build and test
id: build
uses: ros-tooling/[email protected]
Expand All @@ -93,9 +93,9 @@ jobs:
echo "Running clippy in $path"
# Run clippy for all features except generate_docs (needed for docs.rs)
if [ "$(basename $path)" = "rclrs" ]; then
cargo clippy --all-targets -F default,dyn_msg -- -D warnings
cargo clippy --no-deps --all-targets -F default,dyn_msg -- -D warnings
else
cargo clippy --all-targets --all-features -- -D warnings
cargo clippy --no-deps --all-targets --all-features -- -D warnings
fi
cd -
done
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/rust-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ jobs:
- name: Search packages in this repository
id: list_packages
run: |
echo ::set-output name=package_list::$(colcon list --names-only)
{
echo 'package_list<<EOF'
colcon list --names-only
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Setup ROS environment
uses: ros-tooling/[email protected]
Expand All @@ -72,10 +76,6 @@ jobs:
cd -
done
- name: Install cargo-ament-build
run: |
cargo install --debug cargo-ament-build
- name: Build and test
id: build
uses: ros-tooling/[email protected]
Expand All @@ -93,9 +93,9 @@ jobs:
echo "Running clippy in $path"
# Run clippy for all features except generate_docs (needed for docs.rs)
if [ "$(basename $path)" = "rclrs" ]; then
cargo clippy --all-targets -F default,dyn_msg -- -D warnings
cargo clippy --no-deps --all-targets -F default,dyn_msg -- -D warnings
else
cargo clippy --all-targets --all-features -- -D warnings
cargo clippy --no-deps --all-targets --all-features -- -D warnings
fi
cd -
done
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ RUN apt-get update && apt-get install -y \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

# Install Rust and the cargo-ament-build plugin

# Install Rust
USER $CONTAINER_USER
WORKDIR /home/${CONTAINER_USER}
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.75.0 -y
ENV PATH="/home/${CONTAINER_USER}/.cargo/bin:$PATH"
RUN cargo install cargo-ament-build
ENV PATH=/root/.cargo/bin:$PATH


RUN pip install --upgrade pytest

Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ROS 2 for Rust
==============

| Target | Status |
|----------|--------|
| **Ubuntu 20.04** | [![Build Status](https://github.com/ros2-rust/ros2_rust/actions/workflows/rust.yml/badge.svg?branch=main)](https://github.com/ros2-rust/ros2_rust/actions/workflows/rust.yml?branch=main) |
[![Minimal Version Status](https://github.com/ros2-rust/ros2_rust/actions/workflows/rust-minimal.yml/badge.svg?branch=main)](https://github.com/ros2-rust/ros2_rust/actions/workflows/rust-minimal.yml)
[![Stable CI Status](https://github.com/ros2-rust/ros2_rust/actions/workflows/rust-stable.yml/badge.svg?branch=main)](https://github.com/ros2-rust/ros2_rust/actions/workflows/rust-stable.yml)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

Introduction
------------
Expand Down Expand Up @@ -37,7 +37,6 @@ Here are the steps for building the `ros2_rust` examples in a vanilla Ubuntu Foc
# Assuming you installed the minimal version of ROS 2, you need these additional packages:
sudo apt install -y git libclang-dev python3-pip python3-vcstool # libclang-dev is required by bindgen
# Install these plugins for cargo and colcon:
cargo install --debug cargo-ament-build # --debug is faster to install
pip install git+https://github.com/colcon/colcon-cargo.git
pip install git+https://github.com/colcon/colcon-ros-cargo.git

Expand Down
1 change: 0 additions & 1 deletion docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ The exact steps may differ between platforms, but as an example, here is how you
# Assuming you installed the minimal version of ROS 2, you need these additional packages:
sudo apt install -y git libclang-dev python3-pip python3-vcstool # libclang-dev is required by bindgen
# Install these plugins for cargo and colcon:
cargo install cargo-ament-build
pip install git+https://github.com/colcon/colcon-cargo.git
pip install git+https://github.com/colcon/colcon-ros-cargo.git
```
Expand Down
4 changes: 2 additions & 2 deletions rclrs/src/logging/logging_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub(crate) mod log_handler {
pub(crate) message: Cow<'a, str>,
}

impl<'a> LogEntry<'a> {
impl LogEntry<'_> {
/// Change the entry from something borrowed into something owned
pub(crate) fn into_owned(self) -> LogEntry<'static> {
LogEntry {
Expand All @@ -124,7 +124,7 @@ pub(crate) mod log_handler {
pub line_number: usize,
}

impl<'a> LogLocation<'a> {
impl LogLocation<'_> {
pub(crate) fn into_owned(self) -> LogLocation<'static> {
LogLocation {
function_name: Cow::Owned(self.function_name.into_owned()),
Expand Down
6 changes: 3 additions & 3 deletions rclrs/src/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<'a, T: ParameterVariant> ParameterBuilder<'a, T> {
}
}

impl<'a, T> ParameterBuilder<'a, Arc<[T]>>
impl<T> ParameterBuilder<'_, Arc<[T]>>
where
Arc<[T]>: ParameterVariant,
{
Expand All @@ -206,7 +206,7 @@ where
}
}

impl<'a> ParameterBuilder<'a, Arc<[Arc<str>]>> {
impl ParameterBuilder<'_, Arc<[Arc<str>]>> {
/// Sets the default for the parameter from a string-like array.
pub fn default_string_array<U>(mut self, default_value: U) -> Self
where
Expand Down Expand Up @@ -679,7 +679,7 @@ impl std::fmt::Display for DeclarationError {

impl std::error::Error for DeclarationError {}

impl<'a> Parameters<'a> {
impl Parameters<'_> {
/// Tries to read a parameter of the requested type.
///
/// Returns `Some(T)` if a parameter of the requested type exists, `None` otherwise.
Expand Down
12 changes: 6 additions & 6 deletions rclrs/src/publisher/loaned_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ where
pub(super) publisher: &'a Publisher<T>,
}

impl<'a, T> Deref for LoanedMessage<'a, T>
impl<T> Deref for LoanedMessage<'_, T>
where
T: RmwMessage,
{
Expand All @@ -33,7 +33,7 @@ where
}
}

impl<'a, T> DerefMut for LoanedMessage<'a, T>
impl<T> DerefMut for LoanedMessage<'_, T>
where
T: RmwMessage,
{
Expand All @@ -43,7 +43,7 @@ where
}
}

impl<'a, T> Drop for LoanedMessage<'a, T>
impl<T> Drop for LoanedMessage<'_, T>
where
T: RmwMessage,
{
Expand All @@ -66,11 +66,11 @@ where

// SAFETY: The functions accessing this type, including drop(), shouldn't care about the thread
// they are running in. Therefore, this type can be safely sent to another thread.
unsafe impl<'a, T> Send for LoanedMessage<'a, T> where T: RmwMessage {}
unsafe impl<T> Send for LoanedMessage<'_, T> where T: RmwMessage {}
// SAFETY: There is no interior mutability in this type. All mutation happens through &mut references.
unsafe impl<'a, T> Sync for LoanedMessage<'a, T> where T: RmwMessage {}
unsafe impl<T> Sync for LoanedMessage<'_, T> where T: RmwMessage {}

impl<'a, T> LoanedMessage<'a, T>
impl<T> LoanedMessage<'_, T>
where
T: RmwMessage,
{
Expand Down
8 changes: 4 additions & 4 deletions rclrs/src/subscription/readonly_loaned_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ where
pub(super) subscription: &'a Subscription<T>,
}

impl<'a, T> Deref for ReadOnlyLoanedMessage<'a, T>
impl<T> Deref for ReadOnlyLoanedMessage<'_, T>
where
T: Message,
{
Expand All @@ -32,7 +32,7 @@ where
}
}

impl<'a, T> Drop for ReadOnlyLoanedMessage<'a, T>
impl<T> Drop for ReadOnlyLoanedMessage<'_, T>
where
T: Message,
{
Expand All @@ -50,9 +50,9 @@ where

// SAFETY: The functions accessing this type, including drop(), shouldn't care about the thread
// they are running in. Therefore, this type can be safely sent to another thread.
unsafe impl<'a, T> Send for ReadOnlyLoanedMessage<'a, T> where T: Message {}
unsafe impl<T> Send for ReadOnlyLoanedMessage<'_, T> where T: Message {}
// SAFETY: This type has no interior mutability, in fact it has no mutability at all.
unsafe impl<'a, T> Sync for ReadOnlyLoanedMessage<'a, T> where T: Message {}
unsafe impl<T> Sync for ReadOnlyLoanedMessage<'_, T> where T: Message {}

#[cfg(test)]
mod tests {
Expand Down
2 changes: 1 addition & 1 deletion rosidl_runtime_rs/src/string/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::{
struct StringVisitor;
struct WStringVisitor;

impl<'de> Visitor<'de> for StringVisitor {
impl Visitor<'_> for StringVisitor {
type Value = String;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
5 changes: 3 additions & 2 deletions rosidl_runtime_rs/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ pub trait RmwMessage: Clone + Debug + Default + Send + Sync + Message {
///
/// Memory ownership by C is achieved by calling `init()` when any string or sequence is created,
/// as well as in the `Default` impl for messages.
///
/// User code can still create messages explicitly, which will not call `init()`, but this is not a
/// problem, since nothing is allocated this way.
/// problem, since nothing is allocated this way.
///
/// The `Drop` impl for any sequence or string will call `fini()`.
pub trait Message: Clone + Debug + Default + 'static + Send + Sync {
/// The corresponding RMW-native message type.
type RmwMsg: RmwMessage;
Expand Down

0 comments on commit e8f7138

Please sign in to comment.