@@ -7,22 +7,28 @@ use std::ptr::null_mut;
7
7
8
8
/// Extract non-ROS arguments from program's input arguments.
9
9
///
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()`]),
11
11
/// 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.
15
17
///
16
18
/// # Example
17
19
/// ```
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)?;
22
25
/// assert_eq!(non_ros_args.len(), 2);
23
26
/// assert_eq!(non_ros_args[0], "arg1");
24
27
/// assert_eq!(non_ros_args[1], "arg2");
28
+ /// # Ok::<(), RclrsError>(())
25
29
/// ```
30
+ ///
31
+ /// [1]: crate::Context::new
26
32
pub fn extract_non_ros_args (
27
33
args : impl IntoIterator < Item = String > ,
28
34
) -> Result < Vec < String > , RclrsError > {
0 commit comments