Skip to content

Commit 6059506

Browse files
committed
Implicitly cast &str to NodeOptions
Signed-off-by: Michael X. Grey <[email protected]>
1 parent 4c2a67b commit 6059506

File tree

5 files changed

+184
-141
lines changed

5 files changed

+184
-141
lines changed

rclrs/src/executor.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
rcl_bindings::rcl_context_is_valid, ContextHandle, Node, NodeOptions, RclrsError, WaitSet,
2+
rcl_bindings::rcl_context_is_valid, ContextHandle, IntoNodeOptions, Node, RclrsError, WaitSet,
33
WeakNode,
44
};
55
use std::{
@@ -15,8 +15,11 @@ pub struct Executor {
1515

1616
impl Executor {
1717
/// Create a [`Node`] that will run on this Executor.
18-
pub fn create_node(&self, options: impl Into<NodeOptions>) -> Result<Node, RclrsError> {
19-
let options: NodeOptions = options.into();
18+
pub fn create_node<'a>(
19+
&'a self,
20+
options: impl IntoNodeOptions<'a>,
21+
) -> Result<Node, RclrsError> {
22+
let options = options.into_node_options();
2023
let node = options.build(&self.context)?;
2124
self.nodes_mtx.lock().unwrap().push(node.downgrade());
2225
Ok(node)

rclrs/src/node.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ impl Node {
156156
///
157157
/// # Example
158158
/// ```
159-
/// # use rclrs::{Context, InitOptions, RclrsError, NodeOptions};
159+
/// # use rclrs::{Context, InitOptions, RclrsError, IntoNodeOptions};
160160
/// // Without remapping
161161
/// let executor = Context::default().create_basic_executor();
162162
/// let node = executor.create_node(
163-
/// NodeOptions::new("my_node")
163+
/// "my_node"
164164
/// .namespace("/my/namespace")
165165
/// )?;
166166
/// assert_eq!(node.namespace(), "/my/namespace");
@@ -182,10 +182,10 @@ impl Node {
182182
///
183183
/// # Example
184184
/// ```
185-
/// # use rclrs::{Context, RclrsError, NodeOptions};
185+
/// # use rclrs::{Context, RclrsError, IntoNodeOptions};
186186
/// let executor = Context::default().create_basic_executor();
187187
/// let node = executor.create_node(
188-
/// NodeOptions::new("my_node")
188+
/// "my_node"
189189
/// .namespace("/my/namespace")
190190
/// )?;
191191
/// assert_eq!(node.fully_qualified_name(), "/my/namespace/my_node");

0 commit comments

Comments
 (0)