Skip to content

Commit 565d61e

Browse files
committed
Merge remote-tracking branch 'origin/non-ros-arguments' into non-ros-arguments
2 parents 4a448d5 + 4b67972 commit 565d61e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

rclrs/src/arguments.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,28 @@ use std::ptr::null_mut;
77

88
/// Extract non-ROS arguments from program's input arguments.
99
///
10-
/// `args` is expected to be the input arguments of the program (passed via [`std::env::args()`]),
10+
/// `args` is expected to be the input arguments of the program (e.g. [`std::env::args()`]),
1111
/// which are expected to contain at least one element - the executable name.
12-
/// According to rcl documentation, ROS arguments are between `--ros-args` and `--` arguments.
13-
/// Everything else is considered as non-ROS and left unparsed. Extracted non-ROS args are
14-
/// returned in the order that they appear (see example below).
12+
///
13+
/// ROS arguments are arguments between `--ros-args` and `--`, with the final `--` being optional.
14+
/// Everything else is considered as non-ROS arguments and will be left unparsed by
15+
/// [`Context::new()`][1] etc.
16+
/// Extracted non-ROS arguments are returned in the order that they appear by this function.
1517
///
1618
/// # Example
1719
/// ```
18-
/// let input_args : [String;6] = [
19-
/// "arg1", "--ros-args", "some", "args", "--", "arg2"
20-
/// ].map(|x| x.to_string());
21-
/// let non_ros_args = rclrs::extract_non_ros_args(input_args).unwrap();
20+
/// # use rclrs::RclrsError;
21+
/// let input_args = [
22+
/// "arg1", "--ros-args", "some", "args", "--", "arg2"
23+
/// ].map(|x| x.to_string());
24+
/// let non_ros_args = rclrs::extract_non_ros_args(input_args)?;
2225
/// assert_eq!(non_ros_args.len(), 2);
2326
/// assert_eq!(non_ros_args[0], "arg1");
2427
/// assert_eq!(non_ros_args[1], "arg2");
28+
/// # Ok::<(), RclrsError>(())
2529
/// ```
30+
///
31+
/// [1]: crate::Context::new
2632
pub fn extract_non_ros_args(
2733
args: impl IntoIterator<Item = String>,
2834
) -> Result<Vec<String>, RclrsError> {

0 commit comments

Comments
 (0)