Skip to content

Commit a29665a

Browse files
authored
Style and test fixes after recent PRs (#197)
1 parent 5436d57 commit a29665a

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

rclrs/src/node/builder.rs

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,19 @@ impl NodeBuilder {
6464
///
6565
/// # Example
6666
/// ```
67-
/// # use rclrs::{Context, NodeBuilder, RclrsError, RclReturnCode, NodeErrorCode};
67+
/// # use rclrs::{Context, NodeBuilder, RclrsError, RclReturnCode};
6868
/// let context = Context::new([])?;
6969
/// // This is a valid node name
7070
/// assert!(NodeBuilder::new(&context, "my_node").build().is_ok());
7171
/// // This is another valid node name (although not a good one)
7272
/// assert!(NodeBuilder::new(&context, "_______").build().is_ok());
7373
/// // This is an invalid node name
74-
/// assert_eq!(
74+
/// assert!(matches!(
7575
/// NodeBuilder::new(&context, "röböt")
7676
/// .build()
77-
/// .unwrap_err()
78-
/// .code,
79-
/// RclReturnCode::NodeError(NodeErrorCode::NodeInvalidName)
80-
/// );
77+
/// .unwrap_err(),
78+
/// RclrsError::RclError { code: RclReturnCode::NodeInvalidName, .. }
79+
/// ));
8180
/// # Ok::<(), RclrsError>(())
8281
/// ```
8382
///
@@ -116,20 +115,19 @@ impl NodeBuilder {
116115
///
117116
/// # Example
118117
/// ```
119-
/// # use rclrs::{Context, Node, RclrsError, RclReturnCode, NodeErrorCode};
118+
/// # use rclrs::{Context, Node, RclrsError, RclReturnCode};
120119
/// let context = Context::new([])?;
121120
/// // This is a valid namespace
122121
/// let builder_ok_ns = Node::builder(&context, "my_node").namespace("/some/nested/namespace");
123122
/// assert!(builder_ok_ns.build().is_ok());
124123
/// // This is an invalid namespace
125-
/// assert_eq!(
124+
/// assert!(matches!(
126125
/// Node::builder(&context, "my_node")
127126
/// .namespace("/10_percent_luck/20_percent_skill")
128127
/// .build()
129-
/// .unwrap_err()
130-
/// .code,
131-
/// RclReturnCode::NodeError(NodeErrorCode::NodeInvalidNamespace)
132-
/// );
128+
/// .unwrap_err(),
129+
/// RclrsError::RclError { code: RclReturnCode::NodeInvalidNamespace, .. }
130+
/// ));
133131
/// // A missing forward slash at the beginning is automatically added
134132
/// assert_eq!(
135133
/// Node::builder(&context, "my_node")
@@ -243,7 +241,7 @@ impl NodeBuilder {
243241
err,
244242
s: self.namespace.clone(),
245243
})?;
246-
let node_options = self.create_node_options()?;
244+
let rcl_node_options = self.create_rcl_node_options()?;
247245
let rcl_context = &mut *self.context.lock();
248246

249247
// SAFETY: Getting a zero-initialized value is always safe.
@@ -258,7 +256,7 @@ impl NodeBuilder {
258256
node_name.as_ptr(),
259257
node_namespace.as_ptr(),
260258
rcl_context,
261-
&node_options,
259+
&rcl_node_options,
262260
)
263261
.ok()?;
264262
};
@@ -278,9 +276,9 @@ impl NodeBuilder {
278276
/// For detail about default values, see [`NodeBuilder`][1] docs.
279277
///
280278
/// [1]: crate::NodeBuilder
281-
fn create_node_options(&self) -> Result<rcl_node_options_t, RclrsError> {
279+
fn create_rcl_node_options(&self) -> Result<rcl_node_options_t, RclrsError> {
282280
// SAFETY: No preconditions for this function.
283-
let mut node_options = unsafe { rcl_node_get_default_options() };
281+
let mut rcl_node_options = unsafe { rcl_node_get_default_options() };
284282

285283
let cstring_args = self
286284
.arguments
@@ -299,17 +297,17 @@ impl NodeBuilder {
299297
cstring_arg_ptrs.len() as i32,
300298
cstring_arg_ptrs.as_ptr(),
301299
rcutils_get_default_allocator(),
302-
&mut node_options.arguments,
300+
&mut rcl_node_options.arguments,
303301
)
304302
}
305303
.ok()?;
306304

307-
node_options.use_global_arguments = self.use_global_arguments;
308-
node_options.enable_rosout = self.enable_rosout;
305+
rcl_node_options.use_global_arguments = self.use_global_arguments;
306+
rcl_node_options.enable_rosout = self.enable_rosout;
309307
// SAFETY: No preconditions for this function.
310-
node_options.allocator = unsafe { rcutils_get_default_allocator() };
308+
rcl_node_options.allocator = unsafe { rcutils_get_default_allocator() };
311309

312-
Ok(node_options)
310+
Ok(rcl_node_options)
313311
}
314312
}
315313

0 commit comments

Comments
 (0)