Skip to content

Commit 4b67972

Browse files
Nizerlaknnmm
andauthored
Improve doc
Co-authored-by: Nikolai Morin <[email protected]>
1 parent 407ffc5 commit 4b67972

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
@@ -6,22 +6,28 @@ use std::os::raw::c_char;
66

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

0 commit comments

Comments
 (0)