Skip to content

Commit 46cbeaf

Browse files
committed
Extend SubscriptionCallback trait to ReadOnlyLoanedMessage (#266)
This was not a straightforward extension because 1. ReadOnlyLoanedMessage has a lifetime 2. The take_loaned_message() method was restricted to Subscription<T: RmwMessage>, i.e. not available for subscriptions on idiomatic messages. This has been fixed and now the method is implemented for Subscription<T: Message> like the other `take*` methods – though you still will get an RMW-native loaned message even if T is the idiomatic message type, because idiomatic message types can never be loaned.
1 parent f2f00e9 commit 46cbeaf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rclrs/minimal_pub_sub/src/zero_copy_subscriber.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() -> Result<(), Error> {
1212
let _subscription = node.create_subscription::<std_msgs::msg::UInt32, _>(
1313
"topic",
1414
rclrs::QOS_PROFILE_DEFAULT,
15-
move |msg: std_msgs::msg::UInt32| {
15+
move |msg: rclrs::ReadOnlyLoanedMessage<'_, std_msgs::msg::UInt32>| {
1616
num_messages += 1;
1717
println!("I heard: '{}'", msg.data);
1818
println!("(Got {} messages so far)", num_messages);

0 commit comments

Comments
 (0)